mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-18 00:09:06 +01:00
LsformRule: provide reference to LSformElement instead of copied value
This commit is contained in:
parent
5975d36a1c
commit
699631b63c
26 changed files with 26 additions and 26 deletions
|
@ -38,7 +38,7 @@ class LSformRule extends LSlog_staticLoggerClass {
|
|||
*
|
||||
* @return boolean True si les données sont valide, False sinon.
|
||||
*/
|
||||
public static function validate($value,$options=NULL,$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class LSformRule_LSformElement_select_validValue extends LSformRule {
|
|||
*
|
||||
* @return boolean true if the value is valide, false if not
|
||||
*/
|
||||
public static function validate($value,$option,$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
$ret = $formElement -> isValidValue($value);
|
||||
if ($ret===False) return False;
|
||||
return True;
|
||||
|
|
|
@ -37,7 +37,7 @@ class LSformRule_alphanumeric extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate ($value,$options=array(),$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
|
||||
if (LSconfig :: get('params.withAccents', false, 'bool', $options)) {
|
||||
$regex = '/(*UTF8)^[0-9\p{L}]+$/';
|
||||
|
|
|
@ -41,7 +41,7 @@ class LSformRule_callable extends LSformRule {
|
|||
*
|
||||
* @return boolean true if the value is valid, false otherwise
|
||||
*/
|
||||
public static function validate($value,$options,$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
$callable = LSconfig :: get('params.callable', null, null, $options);
|
||||
if (is_callable($callable))
|
||||
return call_user_func_array(
|
||||
|
|
|
@ -67,7 +67,7 @@ class LSformRule_compare extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate ($values,$options=array(),$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
$operator = LSconfig :: get('params.operator', null, 'string', $options);
|
||||
if (!$operator) {
|
||||
LSerror :: addErrorCode('LSformRule_01',array('type' => 'compare', 'param' => 'operator'));
|
||||
|
|
|
@ -37,7 +37,7 @@ class LSformRule_date extends LSformRule {
|
|||
*
|
||||
* @return boolean True si les données sont valide, False sinon.
|
||||
*/
|
||||
public static function validate($value,$options=NULL,$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
$format = LSconfig :: get('params.format', null, 'string', $options);
|
||||
if (is_null($format)) {
|
||||
LSerror :: addErrorCode('LSformRule_date_01');
|
||||
|
|
|
@ -37,7 +37,7 @@ class LSformRule_differentPassword extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value, $options, $formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
$otherPasswordAttributes = LSconfig :: get('params.otherPasswordAttributes', null, null, $options);
|
||||
if (!is_null($otherPasswordAttributes)) {
|
||||
// Make sure otherPasswordAttributes is an array
|
||||
|
|
|
@ -37,7 +37,7 @@ class LSformRule_email extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value,$options=array(),$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
return checkEmail(
|
||||
$value,
|
||||
LSconfig :: get('params.domain', null, null, $options),
|
||||
|
|
|
@ -38,7 +38,7 @@ class LSformRule_filesize extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate ($value,$options,$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
// According to PHP doc, strlen() returns the number of bytes rather
|
||||
// than the number of characters in a string.
|
||||
// See: https://www.php.net/manual/en/function.strlen.php
|
||||
|
|
|
@ -40,7 +40,7 @@ class LSformRule_imagefile extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate ($value,$options,$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
$file = LSsession :: getTmpFile($value);
|
||||
|
||||
$mimetype = mime_content_type($file);
|
||||
|
|
|
@ -40,7 +40,7 @@ class LSformRule_imagesize extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate ($value,$options,$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
$file = LSsession :: getTmpFile($value);
|
||||
list($width, $height, $type, $attr) = getimagesize($file);
|
||||
LSdebug("LSformRule_imagesize :: validate() : image size is $width x $height, type=$type, attr='$attr'");
|
||||
|
|
|
@ -37,7 +37,7 @@ class LSformRule_inarray extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value,$option,$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
$possible_values = LSconfig :: get('params.possible_values', null, null, $options);
|
||||
if (!is_array($possible_values)) {
|
||||
LSerror :: addErrorCode('LSformRule_inarray_01');
|
||||
|
|
|
@ -40,7 +40,7 @@ class LSformRule_integer extends LSformRule{
|
|||
*
|
||||
* @return boolean true if the value is valided, false otherwise
|
||||
*/
|
||||
public static function validate ($value,$options=array(),$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
$max = LSconfig :: get('params.max', null, 'int', $options);
|
||||
if(is_int($max) && $max != 0 && $value > $max) {
|
||||
self :: log_debug("value is too higth ($value > $max)");
|
||||
|
|
|
@ -36,7 +36,7 @@ class LSformRule_lettersonly extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate ($value,$options=array(),$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
$regex = '/^[a-zA-Z]+$/';
|
||||
LSsession :: loadLSclass('LSformRule_regex');
|
||||
return LSformRule_regex :: validate($value,$regex,$formElement);
|
||||
|
|
|
@ -37,7 +37,7 @@ class LSformRule_maxlength extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate ($value,$options,$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
$limit = LSconfig :: get('params.limit', null, 'int', $options);
|
||||
if(is_null($limit)) {
|
||||
LSerror :: addErrorCode('LSformRule_01',array('type' => 'maxlength', 'param' => 'limit'));
|
||||
|
|
|
@ -38,7 +38,7 @@ class LSformRule_mimetype extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate ($value,$options,$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
$file = LSsession :: getTmpFile($value);
|
||||
$real_mimetype = mime_content_type($file);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class LSformRule_minlength extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate ($value,$options,$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
$limit = LSconfig :: get('params.limit', null, 'int', $options);
|
||||
if(is_null($limit)) {
|
||||
LSerror :: addErrorCode('LSformRule_01',array('type' => 'minlength', 'param' => 'limit'));
|
||||
|
|
|
@ -36,7 +36,7 @@ class LSformRule_nonzero extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate ($value,$options,$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
$regex = '/^-?[1-9][0-9]*/';
|
||||
LSsession :: loadLSclass('LSformRule_regex');
|
||||
return LSformRule_regex :: validate($value,$regex,$formElement);
|
||||
|
|
|
@ -36,7 +36,7 @@ class LSformRule_nopunctuation extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate ($value,$options=array(),$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
$regex = '/^[^().\/\*\^\?#!@$%+=,\"\'><~\[\]{}]+$/';
|
||||
LSsession :: loadLSclass('LSformRule_regex');
|
||||
return LSformRule_regex :: validate($value,$regex,$formElement);
|
||||
|
|
|
@ -36,7 +36,7 @@ class LSformRule_numeric extends LSformRule{
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate ($value,$options=array(),$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
$regex = '/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/';
|
||||
LSsession :: loadLSclass('LSformRule_regex');
|
||||
return LSformRule_regex :: validate($value,$regex,$formElement);
|
||||
|
|
|
@ -43,7 +43,7 @@ class LSformRule_password extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate ($value,$options=array(),$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
$maxLength = LSconfig :: get('params.maxLength', null, 'int', $options);
|
||||
if(!is_null($maxLength) && $maxLength != 0 && strlen($value) > $maxLength) {
|
||||
self :: log_debug("password is too long (".strlen($value)." > $maxLength)");
|
||||
|
|
|
@ -38,7 +38,7 @@ class LSformRule_rangelength extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate ($value,$options=array(),$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
$limits = LSconfig :: get('params.limits', null, null, $options);
|
||||
if(!is_array($limits) || count($limits) != 2) {
|
||||
LSerror :: addErrorCode('LSformRule_01',array('type' => 'rangelength', 'param' => 'limits'));
|
||||
|
|
|
@ -37,7 +37,7 @@ class LSformRule_regex extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value, $options, $formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
if (is_array($options)) {
|
||||
$regex = LSconfig :: get('params.regex', null, 'string', $options);
|
||||
if (!is_string($regex)) {
|
||||
|
|
|
@ -36,7 +36,7 @@ class LSformRule_required extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate ($value,$options=NULL,$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
return ((string)$value != '');
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class LSformRule_ssh_pub_key extends LSformRule {
|
|||
*
|
||||
* @return boolean true if the value is valide, false if not
|
||||
*/
|
||||
public static function validate($value,$options,$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
if (preg_match('/^(ssh-[a-z0-9]+) +([^ ]+) +(.*)$/', $value, $m)) {
|
||||
$data=@base64_decode($m[2]);
|
||||
if (is_string($data))
|
||||
|
|
|
@ -36,7 +36,7 @@ class LSformRule_telephonenumber extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value,$options=array(),$formElement) {
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
$regex = '/^(01|02|03|04|05|06|08|09)[0-9]{8}$/';
|
||||
LSsession :: loadLSclass('LSformRule_regex');
|
||||
return LSformRule_regex :: validate($value,$regex,$formElement);
|
||||
|
|
Loading…
Reference in a new issue