FieldValidator
extends ClassDynamic
in package
FieldValidator Class
This class handles all the validation logic
Tags
Table of Contents
Methods
- __call() : mixed
- Magic caller method
- __construct() : mixed
- Construct new validation object
- __get() : mixed
- Magic getter method
- __set() : mixed
- Magic setter method
- getCheck() : string
- Get the validation rule (regular expression)
- getDefaultRequired() : bool
- getError() : string
- Get error message
- getExternalValidation() : array<string|int, mixed>|null
- getExternalValidationError() : string
- getField() : Base
- getFieldHint() : string
- getFieldName() : string
- getFileTypes() : array<string|int, mixed>
- getHintError() : string
- getMatchWith() : Element
- getMatchWithError() : string
- getMaxFiles() : int
- getMaxLength() : int
- getMaxLengthError() : string
- getMaxSize() : int
- getMaxValue() : int
- getMaxValueError() : string
- getMinLength() : int
- getMinLengthError() : string
- getMinValue() : int
- getMinValueError() : string
- getOnlyListItems() : int
- getOnlyListItemsError() : string
- getRequired() : bool
- Get required state
- getRequiredError() : string
- getSanitisers() : array<string|int, mixed>|null
- getType() : int
- getTypeError() : string
- getValidation() : string
- getValidValue() : array<string|int, mixed>|string
- Get the validated value
- getValue() : string|array<string|int, mixed>|null
- Get the value to validate from either the global request variable or the cached __validvalues array.
- preSanitize() : string
- Pre-sanitize a value using a given set of sanitisers or the preset list already available.
- sanitize() : string
- Sanitize a value according to preset rules.
- setDefaultRequired() : void
- setError() : mixed
- Set custom error on a field
- setExternalValidation() : void
- setExternalValidationError() : void
- setField() : void
- setFieldHint() : void
- setFieldName() : void
- setFileTypes() : void
- setHintError() : void
- setMatchWith() : void
- setMatchWithError() : void
- setMaxFiles() : void
- setMaxLength() : void
- setMaxLengthError() : void
- setMaxSize() : void
- setMaxValue() : void
- setMaxValueError() : void
- setMinLength() : void
- setMinLengthError() : void
- setMinValue() : void
- setMinValueError() : void
- setOnlyListItems() : void
- setOnlyListItemsError() : void
- setRequired() : mixed
- Set required state
- setRequiredError() : void
- setSanitisers() : void
- setType() : void
- setTypeError() : void
- setValidation() : void
- validate() : bool
- The most important function of ValidForm Builder library.
Methods
__call()
Magic caller method
public
__call(string $method, mixed $values) : mixed
Parameters
- $method : string
- $values : mixed
Tags
__construct()
Construct new validation object
public
__construct(Element $objField[, array<string|int, mixed> $arrValidationRules = array() ][, array<string|int, mixed> $arrErrorHandlers = array() ][, array<string|int, mixed> $arrSanitizationRules = null ]) : mixed
Parameters
- $objField : Element
- $arrValidationRules : array<string|int, mixed> = array()
- $arrErrorHandlers : array<string|int, mixed> = array()
- $arrSanitizationRules : array<string|int, mixed> = null
__get()
Magic getter method
public
__get(string $property) : mixed
Parameters
- $property : string
Tags
__set()
Magic setter method
public
__set(string $property, mixed $value) : mixed
Parameters
- $property : string
- $value : mixed
Tags
getCheck()
Get the validation rule (regular expression)
public
getCheck() : string
Return values
stringgetDefaultRequired()
public
getDefaultRequired() : bool
getDefaultRequired() Returns the value of $__defaultRequired
Return values
boolgetError()
Get error message
public
getError([int $intDynamicPosition = 0 ]) : string
Parameters
- $intDynamicPosition : int = 0
Return values
stringgetExternalValidation()
public
getExternalValidation() : array<string|int, mixed>|null
getExternalValidation() Returns the value of $__externalvalidation
Return values
array<string|int, mixed>|nullgetExternalValidationError()
public
getExternalValidationError() : string
getExternalValidationError() Returns the value of $__externalvalidationerror
Return values
stringgetField()
public
getField() : Base
getField() Returns the value of $__field
Return values
BasegetFieldHint()
public
getFieldHint() : string
getFieldHint() Returns the value of $__fieldhint
Return values
stringgetFieldName()
public
getFieldName() : string
getFieldName() Returns the value of $__fieldname
Return values
stringgetFileTypes()
public
getFileTypes() : array<string|int, mixed>
getFileTypes() Returns the value of $__filetypes
Return values
array<string|int, mixed>getHintError()
public
getHintError() : string
getHintError() Returns the value of $__hinterror
Return values
stringgetMatchWith()
public
getMatchWith() : Element
getMatchWith() Returns the value of $__matchwith
Return values
ElementgetMatchWithError()
public
getMatchWithError() : string
getMatchWithError() Returns the value of $__onlylistitemserror
Return values
stringgetMaxFiles()
public
getMaxFiles() : int
getMaxFiles() Returns the value of $__maxfiles
Return values
intgetMaxLength()
public
getMaxLength() : int
getMaxLength() Returns the value of $__maxlength
Return values
intgetMaxLengthError()
public
getMaxLengthError() : string
getMaxLengthError() Returns the value of $__maxlengtherror
Return values
stringgetMaxSize()
public
getMaxSize() : int
getMaxSize() Returns the value of $__maxsize
Return values
intgetMaxValue()
public
getMaxValue() : int
getMaxValue() Returns the value of $__maxvalue
Return values
intgetMaxValueError()
public
getMaxValueError() : string
getMaxValueError() Returns the value of $__maxvalueerror
Return values
stringgetMinLength()
public
getMinLength() : int
getMinLength() Returns the value of $__minlength
Return values
intgetMinLengthError()
public
getMinLengthError() : string
getMinLengthError() Returns the value of $__minlengtherror
Return values
stringgetMinValue()
public
getMinValue() : int
getMinValue() Returns the value of $__minvalue
Return values
intgetMinValueError()
public
getMinValueError() : string
getMinValueError() Returns the value of $__minvalueerror
Return values
stringgetOnlyListItems()
public
getOnlyListItems() : int
getOnlyListItems() Returns the value of $__onlylistitems
Return values
intgetOnlyListItemsError()
public
getOnlyListItemsError() : string
getOnlyListItemsError() Returns the value of $__onlylisterror
Return values
stringgetRequired()
Get required state
public
getRequired([bool $blnDefault = false ]) : bool
Parameters
- $blnDefault : bool = false
Return values
boolgetRequiredError()
public
getRequiredError() : string
getRequiredError() Returns the value of $__requirederror
Return values
stringgetSanitisers()
public
getSanitisers() : array<string|int, mixed>|null
getSanitisers() Returns the value of $__sanitisers
Return values
array<string|int, mixed>|nullgetType()
public
getType() : int
getType() Returns the value of $__type
Return values
intgetTypeError()
public
getTypeError() : string
getTypeError() Returns the value of $__typeerror
Return values
stringgetValidation()
public
getValidation() : string
getValidation() Returns the value of $__validation
Return values
stringgetValidValue()
Get the validated value
public
getValidValue([int $intDynamicPosition = 0 ]) : array<string|int, mixed>|string
Parameters
- $intDynamicPosition : int = 0
Return values
array<string|int, mixed>|stringgetValue()
Get the value to validate from either the global request variable or the cached __validvalues array.
public
getValue([int $intDynamicPosition = 0 ]) : string|array<string|int, mixed>|null
Parameters
- $intDynamicPosition : int = 0
-
Using the intDynamicPosition parameter, you can get the specific value of a dynamic field.
Return values
string|array<string|int, mixed>|null —Returns the submitted field value. If no sumitted value is set,
return value is the cached valid value. If no cached value is set, return value is the default value. If no
default value is set, return value is null. When field type is ValidForm::VFORM_FILE and a file is submitted,
the return value is the $_FILES[fieldname] array.
preSanitize()
Pre-sanitize a value using a given set of sanitisers or the preset list already available.
public
preSanitize(mixed $varValue[, null|array<string|int, mixed> $arrSanitisers = null ]) : string
Parameters
- $varValue : mixed
- $arrSanitisers : null|array<string|int, mixed> = null
Return values
stringsanitize()
Sanitize a value according to preset rules.
public
sanitize(mixed $varValue[, null|array<string|int, mixed> $arrSanitisers = null ]) : string
Parameters
- $varValue : mixed
- $arrSanitisers : null|array<string|int, mixed> = null
Return values
stringsetDefaultRequired()
public
setDefaultRequired() : void
setDefaultRequired(boolean $value) Overwrites the value of $__defaultRequired
setError()
Set custom error on a field
public
setError(string $strError[, int $intDynamicPosition = 0 ]) : mixed
Use this to set a custom error on a field
Parameters
- $strError : string
-
Custom error message
- $intDynamicPosition : int = 0
setExternalValidation()
public
setExternalValidation() : void
setExternalValidation(array $value) Overwrites the value of $__externalvalidation
setExternalValidationError()
public
setExternalValidationError() : void
setExternalValidationError(string $value) Overwrites the value of $__externalvalidationerror
setField()
public
setField() : void
setField(Base $value) Overwrites the value of $__field
setFieldHint()
public
setFieldHint() : void
setFieldHint(string $value) Overwrites the value of $__fieldhint
setFieldName()
public
setFieldName() : void
setFieldName(string $value) Overwrites the value of $__fieldname
setFileTypes()
public
setFileTypes() : void
setFileTypes(array $value) Overwrites the value of $__filetypes
setHintError()
public
setHintError() : void
setHintError(string $value) Overwrites the value of $__hinterror
setMatchWith()
public
setMatchWith() : void
setMatchWith(Element $value) Overwrites the value of $__matchwith
setMatchWithError()
public
setMatchWithError() : void
setMatchWithError(string $value) Overwrites the value of $__matchwitherror
setMaxFiles()
public
setMaxFiles() : void
setMaxFiles(integer $value) Overwrites the value of $__maxfiles
setMaxLength()
public
setMaxLength() : void
setMaxLength(integer $value) Overwrites the value of $__maxlength
setMaxLengthError()
public
setMaxLengthError() : void
setMaxLengthError(string $value) Overwrites the value of $__maxlengtherror
setMaxSize()
public
setMaxSize() : void
setMaxSize(integer $value) Overwrites the value of $__maxsize
setMaxValue()
public
setMaxValue() : void
setMaxValue(float $value) Overwrites the value of $__maxvalue
setMaxValueError()
public
setMaxValueError() : void
setMaxValueError(string $value) Overwrites the value of $__maxvalueerror
setMinLength()
public
setMinLength() : void
setMinLength(integer $value) Overwrites the value of $__minlength
setMinLengthError()
public
setMinLengthError() : void
setMinLengthError(string $value) Overwrites the value of $__minlengtherror
setMinValue()
public
setMinValue() : void
setMinValue(float $value) Overwrites the value of $__minvalue
setMinValueError()
public
setMinValueError() : void
setMinValueError(string $value) Overwrites the value of $__minvalueerror
setOnlyListItems()
public
setOnlyListItems() : void
setOnlyListItems(bool $value) Overwrites the value of $__onlylistitems
setOnlyListItemsError()
public
setOnlyListItemsError() : void
setOnlyListItemsError(string $value) Overwrites the value of $__onlylistitemserror
setRequired()
Set required state
public
setRequired(bool $blnValue) : mixed
Parameters
- $blnValue : bool
setRequiredError()
public
setRequiredError() : void
setRequiredError(string $value) Overwrites the value of $__requirederror
setSanitisers()
public
setSanitisers() : void
setSanitisers(array $value) Overwrites the value of $__sanitisers
setType()
public
setType() : void
setType(integer $value) Overwrites the value of $__type
setTypeError()
public
setTypeError() : void
setTypeError(string $value) Overwrites the value of $__typeerror
setValidation()
public
setValidation() : void
setValidation(string $value) Overwrites the value of $__validation
validate()
The most important function of ValidForm Builder library.
public
validate([int $intDynamicPosition = 0 ]) : bool
This function handles all the server-side field validation logic.
Parameters
- $intDynamicPosition : int = 0
-
Using the intDynamicPosition parameter, you can validate a specific dynamic field, if necessary.
Return values
bool —True if the current field validates, false if not.