HasValidators
trait HasValidators
Supports ability to validate console input.
Properties
| protected array | $errors | An array of errors. |
|
| protected string | $fieldName | The name of the field to be validated. |
|
| protected array | $reservedKeywords | An array of reserved keywords. |
|
| protected array | $reservedSQLKeyWords | ||
| protected array | $validators | Array of validator callbacks. |
Methods
Adds a new error message to the $errors array.
Enforce rule where input must contain only alphabetic characters.
Enforce rule where input must be alphanumeric characters.
Ensures input is between within a certain range in length.
Checks if class exists within the specified namespace.
Ensures response is in colon notation format.
Tests form validation with multiple fields. Used by the unique validator to test several fields for uniqueness.
Enforce rule where response and $match parameter needs to be different.
Displays a list of all error messages.
Ensures response is in dot notation format.
Ensures input is a valid E-mail address.
Sets name of field to be validated.
Supports includeDeleted feature for database operations.
Enforce rule where input must be an integer.
Enforce rule where input must be a valid IP address.
Checks if a port on a particular host is in use. Assists in verifying if a port is available for a serve command. If the port is already in use an error message is presented to the user.
Ensure user inputs valid comma separated list of values. The user must provide the following in the $attributes parameter: 1) Class containing full namespaced path 2) Name of function that returns an array of strings or a comma separated array of strings.
Enforces rule when input must contain at least one lower case character.
Enforce rule where response and $match parameter needs to match.
Ensures input meets requirements for maximum allowable length.
Ensures input meets requirements for minimum allowable length.
Enforces rule when input must be a negative number.
Enforces rule when input must contain no special characters.
Enforce rule when reserved keywords should be avoided.
Enforce rule when reserved SQL keywords should be avoided.
Enforces rule when input must contain at least one numeric character.
Enforce rule where input must contain only numeric characters.
Parse array containing additional validators or attributes for FrameworkQuestion as strings along with any additional parameters that maybe expected.
Ensures required input is entered.
Enforces rule when input must a positive number.
Validates if queue exists in database or redis.
Adds validator to array of validators to be used.
Enforces rule when input must contain at least one special character.
Enforces rule where input must be a valid phone number.
Ensures response is in colon notation format.
Split on commas (tolerate spaces), normalize to lowercase, drop empties.
Checks if value already exists in a database.
Enforces rule when input must contain at least one lower case character.
Enforce rule where input must be a valid URL.
Calls validator callbacks. This function also ensures validators don't bleed into next question if instance is reused.
Details
at line 127
void
addErrorMessage(string $message)
Adds a new error message to the $errors array.
at line 137
HasValidators
alpha()
Enforce rule where input must contain only alphabetic characters.
at line 151
HasValidators
alphaNumeric()
Enforce rule where input must be alphanumeric characters.
at line 169
HasValidators
between(array $range)
Ensures input is between within a certain range in length.
at line 194
HasValidators
classExists(string|array $namespace)
Checks if class exists within the specified namespace.
at line 209
HasValidators
colonNotation()
Ensures response is in colon notation format.
at line 231
void
compositeFieldValidation(array|string $additionalFieldData, array $conditions, array $bind)
Tests form validation with multiple fields. Used by the unique validator to test several fields for uniqueness.
at line 254
HasValidators
different(mixed $data)
Enforce rule where response and $match parameter needs to be different.
at line 269
void
displayErrorMessages()
Displays a list of all error messages.
at line 285
HasValidators
dotNotation()
Ensures response is in dot notation format.
at line 302
HasValidators
email()
Ensures input is a valid E-mail address.
at line 317
HasValidators
fieldName(string|array $fieldName)
Sets name of field to be validated.
at line 333
void
includeDeleted(bool|string $includeDeleted, array $queryParams)
Supports includeDeleted feature for database operations.
at line 344
HasValidators
integer()
Enforce rule where input must be an integer.
at line 358
HasValidators
ip()
Enforce rule where input must be a valid IP address.
at line 376
HasValidators
isPortUsed(array $attributes)
Checks if a port on a particular host is in use. Assists in verifying if a port is available for a serve command. If the port is already in use an error message is presented to the user.
at line 405
HasValidators
list(array $attributes)
Ensure user inputs valid comma separated list of values. The user must provide the following in the $attributes parameter: 1) Class containing full namespaced path 2) Name of function that returns an array of strings or a comma separated array of strings.
3) A string value in this array as an alias (optional).
at line 443
HasValidators
lower()
Enforces rule when input must contain at least one lower case character.
at line 458
HasValidators
match(mixed $match)
Enforce rule where response and $match parameter needs to match.
at line 474
HasValidators
max(int|array $maxRule)
Ensures input meets requirements for maximum allowable length.
at line 490
HasValidators
min(int|array $minRule)
Ensures input meets requirements for minimum allowable length.
at line 505
HasValidators
negative()
Enforces rule when input must be a negative number.
at line 519
HasValidators
noSpecialChars()
Enforces rule when input must contain no special characters.
at line 533
HasValidators
notReservedKeyword()
Enforce rule when reserved keywords should be avoided.
at line 547
HasValidators
notReservedSQLKeyword()
Enforce rule when reserved SQL keywords should be avoided.
at line 561
HasValidators
number()
Enforces rule when input must contain at least one numeric character.
at line 575
HasValidators
numeric()
Enforce rule where input must contain only numeric characters.
at line 597
static protected void
parseAttributes(object $object, array $validators)
Parse array containing additional validators or attributes for FrameworkQuestion as strings along with any additional parameters that maybe expected.
at line 618
HasValidators
required()
Ensures required input is entered.
at line 631
HasValidators
positive()
Enforces rule when input must a positive number.
at line 645
HasValidators
queue()
Validates if queue exists in database or redis.
at line 670
HasValidators
setValidator(callable $validator)
Adds validator to array of validators to be used.
at line 680
HasValidators
special()
Enforces rule when input must contain at least one special character.
at line 694
HasValidators
tel()
Enforces rule where input must be a valid phone number.
at line 718
HasValidators
testFilterNotation()
Ensures response is in colon notation format.
at line 739
static protected array
tokens(string $data)
Split on commas (tolerate spaces), normalize to lowercase, drop empties.
Useful for cases where you have a comma separated string.
at line 752
HasValidators
unique(array $attributes)
Checks if value already exists in a database.
at line 796
HasValidators
upper()
Enforces rule when input must contain at least one lower case character.
at line 810
HasValidators
url()
Enforce rule where input must be a valid URL.
at line 826
protected bool
validate(mixed $response)
Calls validator callbacks. This function also ensures validators don't bleed into next question if instance is reused.