<?php

/**
 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @package fusionLib
 * @copyright Copyright (c) 2013 fusionLib. All rights reserved.
 * @link http://fusionlib.com
 */

/**
 * flFormValidatorAttribMax Class
 *
 * Verify the input is below a maximum value as specified by the max attribute on the element.
 * Note: Only client side validation is performed.
 *
 * @package fusionLib
 */
class flFormValidatorAttribMax extends flFormValidator {

	/**
	 * Construct the validator.
	 *
	 * @param string $message The optional message.
	 */
	function __construct($message = null) {
		parent::__construct($message, __('{label} must be {value} or less.', 'fusionLib'));
	}

	/**
	 * Validate the input.
	 *
	 * @param flFormElement $elem The form element to validate.
	 * @return bool true if the input is valid; else false.
	 */
	function validate($elem) {
		parent::validate($elem);
		return true;
	}

	/**
	 * Get the client side rule for validation.
	 *
	 * @return array [0] The string holding the rule information for use with fusionLib.validation.js
	 * [1] true to use ajax or false, if false is returned instead of an array then no client side validation is done
	 */
	function getClientRule() {
		return array('attribmax: {' . ($this->message === null ? '' : $this->getClientMsg()) . '}', false);
	}
}
