*/ class LSformRule_maxlength extends LSformRule { // CLI parameters autocompleters protected static $cli_params_autocompleters = array( 'limit' => array('LScli', 'autocomplete_int'), ); /** * Validate form element value * * @param mixed $value The value to validate * @param array $options Validation options: * - Maximum length : $options['params']['limit'] * @param LSformElement &$formElement The related LSformElement object * * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { $limit = LSconfig :: get('params.limit', null, 'int', $options); if(is_null($limit)) { LSerror :: addErrorCode('LSformRule_01',array('type' => 'maxlength', 'param' => 'limit')); return false; } return (strlen($value) <= $limit); } }