Class that allows us to manage application validation in an encapsulated way.
We can create as many instances as we want, and each instance will store the validation history and global validation state,
so we can use this class to validate complex forms or multiple elements globally.
We can also use tags to sandbox different validation elements or groups togheter.
Methods
Protection to prevent accessing undefined properties to this class
__get(string $name): void
inherited
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Arguments
$name
string
The property name
Protection to prevent creating extra properties to this class
__set(string $name,string $value): void
inherited
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Arguments
$name
string
The property name
$value
string
The property value
Find the first error or warning message that happened since the validation manager was instantiated or
since the last reset
getFirstMessage(string|array $tags = ''): string
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Arguments
$tags
string|array
If we want to filter only the warning / error messages by tag or list of tags, we can set it here. If we want to
get the first of all messages, no matter which tag was applied, we will leave this value empty ''.
Response
string
The first error or warning message or empty string if no message exists
Find the latest error or warning message that happened since the validation manager was instantiated or
since the last reset
getLastMessage(string|array $tags = ''): string
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Arguments
$tags
string|array
If we want to filter only the warning / error messages by tag or list of tags, we can set it here. If we want to
get the latest of all messages, no matter which tag was applied, we will leave this value empty ''.
Response
string
The last error or warning message or empty string if no message exists
Check the current validation state.
getStatus(string|array $tags = ''): integer
Possible return values are ValidationManager.OK, ValidationManager.WARNING or ValidationManager.ERROR
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Arguments
$tags
string|array
If we want to check the validation state for a specific tag or a list of tags, we can set it here. If we want to
get the global validation state for all the tags we will leave this value empty ''.
Response
integer
ValidationManager.OK, ValidationManager.WARNING or ValidationManager.ERROR
Validation will fail if specified value is not an array
isArray(mixed $value,string $errorMessage = 'value is not an array',mixed $tags = '',boolean $isWarning = false): boolean
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Arguments
$value
mixed
The array to validate
$errorMessage
string
The error message that will be generated if validation fails
$tags
mixed
We can define a tag name or list of tags to group the validation results. We can use this tags later to filter validation state
$isWarning
boolean
Tells if the validation fail will be processed as a validation error or a validation warning
Response
boolean
False in case the validation fails or true if validation succeeds.
Validation will fail if specified value is not a boolean
isBoolean(mixed $value,string $errorMessage = 'value is not a boolean',mixed $tags = '',boolean $isWarning = false): boolean
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Arguments
$value
mixed
The boolean to validate
$errorMessage
string
The error message that will be generated if validation fails
$tags
mixed
We can define a tag name or list of tags to group the validation results. We can use this tags later to filter validation state
$isWarning
boolean
Tells if the validation fail will be processed as a validation error or a validation warning
Response
boolean
False in case the validation fails or true if validation succeeds.
TODO - translate from TS
isDate()
|
|
|
|
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Validation will fail if specified elements are not identical.
isEqualTo(mixed $value,mixed $value2,string $errorMessage = 'values are not equal',mixed $tags = '',boolean $isWarning = false): boolean
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Arguments
$value
mixed
First of the two objects to compare. Almost any type can be provided: ints, strings, arrays...
$value2
mixed
Second of the two objects to compare. Almost any type can be provided: ints, strings, arrays...
$errorMessage
string
The error message that will be generated if validation fails
$tags
mixed
We can define a tag name or list of tags to group the validation results. We can use this tags later to filter validation state
$isWarning
boolean
Tells if the validation fail will be processed as a validation error or a validation warning
Response
boolean
False in case the validation fails or true if validation succeeds.
Validation will fail if specified text is empty.<br>
See Stringutils.isEmpty to understand what is considered as an empty text
isFilledIn(string $value,array $emptyChars = array(),string $errorMessage = 'value is required',mixed $tags = '',boolean $isWarning = false): boolean
see
|
\org\turbocommons\src\main\php\managers\Stringutils::isEmpty |
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Arguments
$value
string
A text that must not be empty.
$emptyChars
array
Optional array containing a list of string values that will be considered as empty for the given string. This can be useful in some cases when we want to consider a string like 'NULL' as an empty string.
$errorMessage
string
The error message that will be generated if validation fails
$tags
mixed
We can define a tag name or list of tags to group the validation results. We can use this tags later to filter validation state
$isWarning
boolean
Tells if the validation fail will be processed as a validation error or a validation warning
Response
boolean
False in case the validation fails or true if validation succeeds.
TODO - translate from TS
isMail()
|
|
|
|
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
TODO - translate from TS
isMaximumLength()
|
|
|
|
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
TODO - translate from TS
isMinimumLength()
|
|
|
|
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
TODO - translate from TS
isMinimumWords()
|
|
|
|
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
TODO - translate from TS
isNIF()
|
|
|
|
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Validation will fail if specified value is not numeric
isNumeric(mixed $value,string $errorMessage = 'value is not a number',mixed $tags = '',boolean $isWarning = false): boolean
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Arguments
$value
mixed
The number to validate
$errorMessage
string
The error message that will be generated if validation fails
$tags
mixed
We can define a tag name or list of tags to group the validation results. We can use this tags later to filter validation state
$isWarning
boolean
Tells if the validation fail will be processed as a validation error or a validation warning
Response
boolean
False in case the validation fails or true if validation succeeds.
Validation will fail if specified value is not numeric and between the two provided values.
isNumericBetween(mixed $value, $min, $max,string $errorMessage = 'value is not between min and max',mixed $tags = '',boolean $isWarning = false): boolean
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Arguments
$value
mixed
The number to validate
$errorMessage
string
The error message that will be generated if validation fails
$tags
mixed
We can define a tag name or list of tags to group the validation results. We can use this tags later to filter validation state
$isWarning
boolean
Tells if the validation fail will be processed as a validation error or a validation warning
Response
boolean
False in case the validation fails or true if validation succeeds.
Validation will fail if specified value is not an object
isObject(mixed $value,string $errorMessage = 'value is not an object',mixed $tags = '',boolean $isWarning = false): boolean
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Arguments
$value
mixed
The object to validate
$errorMessage
string
The error message that will be generated if validation fails
$tags
mixed
We can define a tag name or list of tags to group the validation results. We can use this tags later to filter validation state
$isWarning
boolean
Tells if the validation fail will be processed as a validation error or a validation warning
Response
boolean
False in case the validation fails or true if validation succeeds.
TODO - translate from TS
isPhone()
|
|
|
|
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
TODO - translate from TS
isPostalCode()
|
|
|
|
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Validation will fail if specified value is not a string
isString(mixed $value,string $errorMessage = 'value is not a string',mixed $tags = '',boolean $isWarning = false): boolean
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Arguments
$value
mixed
The element to validate
$errorMessage
string
The error message that will be generated if validation fails
$tags
mixed
We can define a tag name or list of tags to group the validation results. We can use this tags later to filter validation state
$isWarning
boolean
Tells if the validation fail will be processed as a validation error or a validation warning
Response
boolean
False in case the validation fails or true if validation succeeds.
Validation will fail if specified value is not a true boolean value
isTrue(mixed $value,string $errorMessage = 'value is not true',mixed $tags = '',boolean $isWarning = false): boolean
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Arguments
$value
mixed
A boolean expression to validate
$errorMessage
string
The error message that will be generated if validation fails
$tags
mixed
We can define a tag name or list of tags to group the validation results. We can use this tags later to filter validation state
$isWarning
boolean
Tells if the validation fail will be processed as a validation error or a validation warning
Response
boolean
False in case the validation fails or true if validation succeeds.
Validation will fail if specified value is not an url
isUrl(mixed $value,string $errorMessage = 'value is not an URL',mixed $tags = '',boolean $isWarning = false): boolean
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Arguments
$value
mixed
The element to validate
$errorMessage
string
The error message that will be generated if validation fails
$tags
mixed
We can define a tag name or list of tags to group the validation results. We can use this tags later to filter validation state
$isWarning
boolean
Tells if the validation fail will be processed as a validation error or a validation warning
Response
boolean
False in case the validation fails or true if validation succeeds.
Provides a way to perform a fast validation check. Will return true if validation manager is in a warning or error state, or false
if validation state is ok.
notOk(string|array $tags = ''): boolean
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Arguments
$tags
string|array
If we want to check the validation state for a specific tag or a list of tags, we can set it here. If we want to
get the global validation state for all the tags we will leave this value empty ''.
Response
boolean
True if status is warning or error, False if status is ok
Provides a way to perform a fast validation check. Will return true if validation state is ok, or false if validation
manager is in a warning or error state.
ok(string|array $tags = ''): boolean
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Arguments
$tags
string|array
If we want to check the validation state for a specific tag or a list of tags, we can set it here. If we want to
get the global validation state for all the tags we will leave this value empty ''.
Response
boolean
True if status is ok, false if status is warning or error
Reinitialize the validation status.
reset(): void
This is normally called at the beginning of every global validation we perform. It will reset all the validation
errors on this class and for all tags, so we can re validate whatever we need to.
|
|
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
Constants
Constant that defines the correct validation status
OK
Constant that defines the warning validation status
WARNING
Constant that defines the error validation status
ERROR