/** * * Method to validate user inputs, if not: set field property isValid to false and set error message * @param string $inputType user input type (postValue, queryValue) */ protected function validateUserInput($inputType) { $type = $this->type; $value = $this->{$inputType}; //Empty value is valid if ($value == "") { return; } //if a value is set we test it is a valid number (which still may have dots and commas if (VisformsValidate::validate($type, array('value' => $value))) { return; } else { //invalid user inputs - set field->isValid to false $this->field->isValid = false; //set the Error Message VisformsMessage::getMessage($this->field->name, $type); return; } }
/** * * Method to validate user inputs, if not: set field property isValid to false and set error message * @param string $inputType user input type (postValue, queryValue) */ protected function validateUserInput($inputType) { $type = $this->type; $value = $this->{$inputType}; //Empty value is valid if ($value == "") { return true; } //if a value is set we test it has a valid date format if (VisformsValidate::validate($type, array('value' => $value, 'format' => $this->field->dateFormatPhp))) { return true; } else { //invalid date format - set field->isValid to false $this->field->isValid = false; //set the Error Message VisformsMessage::getMessage($this->field->name, $type, array('format' => $this->field->dateFormatPhp)); //we cannot use the value! return false; } }