Open Journal Systems  3.3.0
FormValidator Class Reference
Inheritance diagram for FormValidator:
FormValidatorArray FormValidatorArrayCustom FormValidatorBoolean FormValidatorControlledVocab FormValidatorCSRF FormValidatorCustom FormValidatorEmail FormValidatorInSet FormValidatorISSN FormValidatorLength FormValidatorLocale FormValidatorORCID FormValidatorPost FormValidatorReCaptcha FormValidatorRegExp FormValidatorUrl FormValidatorUsername

Public Member Functions

 __construct (&$form, $field, $type, $message, $validator=null)
 
 getField ()
 
 getFieldValue ()
 
getForm ()
 
 getMessage ()
 
 getType ()
 
getValidator ()
 
 isEmptyAndOptional ()
 
 isValid ()
 

Data Fields

 $_field
 
 $_form
 
 $_message
 
 $_type
 
 $_validator
 

Detailed Description

Class to represent a form validation check.

Definition at line 23 of file FormValidator.inc.php.

Constructor & Destructor Documentation

◆ __construct()

FormValidator::__construct ( $form,
  $field,
  $type,
  $message,
  $validator = null 
)

Constructor.

Parameters
$formForm the associated form
$fieldstring the name of the associated field
$typestring the type of check, either "required" or "optional"
$messagestring the error message for validation failures (i18n key)
$validatorValidator the validator used to validate this form field (optional)

Reimplemented in FormValidatorLocaleEmail, FormValidatorLocaleUrl, FormValidatorRegExp, FormValidatorArray, and FormValidatorInSet.

Definition at line 63 of file FormValidator.inc.php.

Member Function Documentation

◆ getField()

FormValidator::getField ( )

Get the field associated with the check.

Returns
string

Definition at line 84 of file FormValidator.inc.php.

References $_field.

Referenced by FormValidatorLocale\getFieldValue(), getFieldValue(), FormValidatorBoolean\isValid(), FormValidatorArray\isValid(), and FormValidatorArrayCustom\isValid().

◆ getFieldValue()

◆ getForm()

& FormValidator::getForm ( )

Get the form associated with the check

Returns
Form

Definition at line 100 of file FormValidator.inc.php.

References $_form.

Referenced by FormValidatorLocale\getFieldValue(), getFieldValue(), FormValidatorBoolean\isValid(), and FormValidatorReCaptcha\isValid().

◆ getMessage()

FormValidator::getMessage ( )

Get the error message associated with a failed validation check.

Returns
string

Reimplemented in FormValidatorCustom, FormValidatorLength, FormValidatorLocale, and FormValidatorEmail.

Definition at line 92 of file FormValidator.inc.php.

◆ getType()

FormValidator::getType ( )

Get the type of the validated field ('optional' or 'required')

Returns
string

Definition at line 116 of file FormValidator.inc.php.

References $_type.

Referenced by isEmptyAndOptional(), FormValidatorArray\isValid(), and FormValidatorArrayCustom\isValid().

◆ getValidator()

& FormValidator::getValidator ( )

Get the validator associated with the check

Returns
Validator

Definition at line 108 of file FormValidator.inc.php.

References $_validator.

Referenced by isValid().

◆ isEmptyAndOptional()

FormValidator::isEmptyAndOptional ( )

Check if field value is empty and optional.

Returns
boolean

Definition at line 165 of file FormValidator.inc.php.

References getFieldValue(), and getType().

Referenced by FormValidatorInSet\isValid(), FormValidatorLength\isValid(), FormValidatorCustom\isValid(), FormValidatorArrayCustom\isValid(), and isValid().

◆ isValid()

FormValidator::isValid ( )

Check if field value is valid. Default check is that field is either optional or not empty.

Returns
boolean

Reimplemented in FormValidatorArrayCustom, FormValidatorCustom, FormValidatorLength, FormValidatorArray, FormValidatorReCaptcha, FormValidatorInSet, FormValidatorBoolean, FormValidatorCSRF, and FormValidatorPost.

Definition at line 129 of file FormValidator.inc.php.

References getFieldValue(), getValidator(), and isEmptyAndOptional().

Field Documentation

◆ $_field

string FormValidator::$_field

The name of the field

Definition at line 35 of file FormValidator.inc.php.

Referenced by getField().

◆ $_form

Form FormValidator::$_form

The Form associated with the check

Definition at line 29 of file FormValidator.inc.php.

Referenced by getForm().

◆ $_message

string FormValidator::$_message

The error message associated with a validation failure

Definition at line 47 of file FormValidator.inc.php.

◆ $_type

string FormValidator::$_type

The type of check ("required" or "optional")

Definition at line 41 of file FormValidator.inc.php.

Referenced by getType().

◆ $_validator

Validator FormValidator::$_validator

The validator used to validate the field

Definition at line 53 of file FormValidator.inc.php.

Referenced by getValidator().


The documentation for this class was generated from the following file: