Download the PHP package codesvault/validator without Composer
On this page you can find all versions of the php package codesvault/validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download codesvault/validator
More information about codesvault/validator
Files in codesvault/validator
Informations about the package validator
Validator
Data validation composer package.
Installation
Install using composer.
Usage
It'll get data from $_REQUEST
by default. But you also can pass data as second parameter.
Available Rules
Rule | Description |
---|---|
required | Check the value is present in the input data and is not empty. |
Check the value is valid email address. | |
url | Check the value is valid url. |
string | Check the value is string. |
stringOnly | Check the value is only string charecters. |
stringWithSpace | Check the value is string with space. |
stringWithNumber | Check the value is string with number. |
stringWithDash | Check the value is string with dash and underscore. |
uppercase | Check the value is string with upper case. |
lowercase | Check the value is string with lower case. |
mixedCase | Check the value is string with upper and lower case. |
stringWithSymbols | Check the value is string with symbols. |
min | Check the value is greater than or equal to the given value. |
max | Check the value is less than or equal to the given value. |
integer | Check the value is integer. |
sameValue | Check the value is same as the given value. |
array | Check the value is an array. |
each | validate each item of an array. |
Examples
Basic Validation Rules
Required Rule
Ensures the field is present and not empty.
Email Rule
Validates email address format.
URL Rule
Validates URL format.
String Validation Rules
String Only (stringOnly)
Validates that the value contains only alphabetic characters.
String with Spaces (stringWithSpace)
Validates strings that can contain alphabetic characters and spaces.
String with Numbers (stringWithNumber)
Validates strings that can contain alphabetic characters and numbers.
String with Dash (stringWithDash)
Validates strings that can contain alphabetic characters, dashes, and underscores.
Case Validation Rules
String with Symbols (stringWithSymbols)
Validates strings that can contain symbols and special characters.
Length Validation Rules
Minimum Length (min)
Validates minimum length/size requirements.
Maximum Length (max)
Validates maximum length/size requirements.
Data Type Rules
Integer Rule
Validates that the value is an integer.
Array Rule
Validates that the value is an array.
Advanced Rules
Same Value (sameValue)
Validates that the field value matches a specific value.
Each Rule
Validates each item in an array against specified rules.
Form validation with Combining Multiple Rules
You can combine multiple rules using the pipe (|
) separator:
Error Handling Example
If any data is invalid then error
method will return error messages array. Otherwise it'll return empty array.