List of Rules
PHPValidator provides a variety of predefined rules that you can use for data validation. Here is a list of some commonly used rules along with examples of their usage:
-
Required Rule
- Ensures that a field is present in the data.
-
String Rule
- Checks if a field is of string type.
-
Email Rule
- Validates that a field is a well-formed email address.
-
Max Length Rule
- Specifies the maximum length of a string field.
-
Confirmed Rule
- Checks if a field's value is the same as another field (commonly used for password confirmation).
-
File Rule
- Validates that a field is a file upload.
-
Accepted Rule
- Validates that a field is
"yes","on","1", ortrue. Useful for checkboxes.
- Validates that a field is
-
Accepted If Rule
- Validates that a field is accepted if another field is equal to a specified value.
-
ActiveURL Rule
- Validates that a field is a valid, active URL.
-
Alpha Rule
- Validates that a field contains only alphabetic characters.
-
Numeric Rule
- Validates that a field contains only numeric characters.
-
Lowercase Rule
- Validates that a field contains only lowercase alphabetic characters.
-
Uppercase Rule
- Validates that a field contains only uppercase alphabetic characters.
-
In Rule
- Validates that a field's value is among a list of predefined values.
-
Nullable Rule
- Allows a field to be
nullor empty.
- Allows a field to be
-
Password Rule
- Validates that a field is a
secure password.
- Validates that a field is a
-
Same Rule
- Validates that a field's value is the same as the value of another field.
-
Max Length Rule
- Specifies the minimum length of a string field.
-
Not In Rule
- Validates that a field's value is not in a specified set.
-
Required With Rule
- Requires the field to be present if another specified field is present.
-
Valid IP Rule
- Validates that a field's value is a valid IP address.
-
Json Rule
- Validates that a field's value is a valid JSON string.
-
URL Rule
- Validates that a field's value is a valid URL.
-
Alpha Numeric Rule
- Validates that a field's value contains only alphanumeric characters.
-
Boolean Rule
- Validates that a field's value is a boolean.
-
Size Rule
- Validates that the size of a string, integer, array, or file is equal to a specified value.