Download the PHP package wamesk/laravel-validator without Composer
On this page you can find all versions of the php package wamesk/laravel-validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-validator
Laravel Validator
Laravel package that extends default laravel validator
- Laravel Validator
- Laravel package that extends default laravel validator
- Installation
- Validator
- Validate function
- Code function
- Messages function
- Status Code function
- Rules
- Exists rule
- IsInteger rule
- IsString rule
- IsArray rule
Installation
Publish translations
Validator
Validator used by default in this package.
It works by chaining functions and getting response.
Response is generated by wamesk/laravel-api-response
package functions.
To better understand how response works checkout documentation for response package here
Validate function
This function is final function. Always last. It requires data and rules for validation. Documentation for rules click here
Usage example:
In case of validation error it will return
Code function
This function is add internal code in response. You can pass second parameter that changes prefix for message translation.
Usage example:
In case of validation error it will return
Messages function
This function adds custom response for validation. You need to pass objects of which key is field, and it's validation. As value, you pass your custom message as shown in example.
Usage example:
In case of validation error it will return
Status Code function
This function doesn't change response visually but changes status code of response. Default status code is 400 (Bad Request). If you want to chain all functions it can look like this. Status code is always integer.
Rules
This package also provides you with these custom rules for your project.
Usage:
Exists rule
This rule validates if entity exists. It requires model class in construct. Firstly it validates if there is entity with this parameter in database. Secondly it checks if it wasn't deleted, if it was it returns validation error. You can pass second (optional) parameter column name.
IsInteger rule
This rule validates if attribute is integer. You can pass additional data (min, max) in construct to create range of acceptable integers.
IsString rule
This rule validates if attribute is string. You can pass additional data (min, max) to validate length of string.
IsArray rule
This rule validates if attribute is array. You can pass additional data (min, max) to validate length of array.
IsEmail rule
Validates email format, checks domain existence, and optionally blocks temporary email domains in Laravel. You can pass additional data (true, false) to enable some functions.
All versions of laravel-validator with dependencies
laravel/framework Version ^9.0|^10.0
wamesk/laravel-api-response Version ^1.0