Download the PHP package ekut/spatie-dto-validators without Composer
On this page you can find all versions of the php package ekut/spatie-dto-validators. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ekut/spatie-dto-validators
More information about ekut/spatie-dto-validators
Files in ekut/spatie-dto-validators
Package spatie-dto-validators
Short Description Set of validators for the package spatie/data-transfer-object
License MIT
Informations about the package spatie-dto-validators
Set of validators for spatie/data-transfer-object package
Installation
You can install the package via composer:
- Note: This package only supports
php:^8.0
.
Usage
As you can see in Spatie DTO documentation Validation chapter:
So, in this package we just collect set of tested validators for you can easily use it in your projects together with Spatie DTO.
If any of the validation will be violated, Spatie\DataTransferObject\Exceptions\ValidationException
will be thrown
with related user-friendly text message.
List of implemented validators
Basic
Blank
Valid values:
- false (boolean)
- 0 (int)
- [] (empty array
- '' (empty string)
- "" (empty string)
-
null
- Note: string '0' is invalid value.
NotBlank
Boolean argument means: is null allowed?
Invalid values:
- false (boolean)
- 0 (int)
- [] (empty array
- '' (empty string)
- "" (empty string)
-
null (if null is not allowed by argument)
- Note: string '0' is valid value.
NotNull
Only invalid value: null
IsNull
Only valid value: null
IsTrue
Valid values:
- true (boolean)
- 1 (int)
- '1' (string)
IsFalse
Valid values:
- false (boolean)
- 0 (int)
- '0' (string)
- null
Strings
MinLength
Valid: 'car', 'lady', 333, etc.
Invalid: 'on', 'a', 12, 1, etc.
MaxLength
Valid: 'car', 'on', 'a', 333, 12, 1.
Invalid: 'lady', 'month', 9999, etc.
Valid: '[email protected]', '[email protected]', '[email protected]', '[email protected]'.
Invalid: 'fake.com', 'fake@com'.
Url
Valid:
- https://www.example.com,
- http://www.example.com,
- http://blog.example.com,
- http://www.example.com/product,
- http://www.example.com/products?id=1&page=2,
- http://www.example.com#up,
- http://www.site.com:8008,
- //www.site.com:8008
Invalid: 'some fake', 'www.example.com', 'example.com'
Comparison
EqualTo
Valid values: 3, '3'.
NotEqualTo
Invalid values: 3, '3'.
IdenticalTo
Only valid value: 3.
NotIdenticalTo
Only invalid value: 3.
LessThan
LessThanOrEqual
GreaterThan
GreaterThanOrEqual
DivisibleBy
Choice
Choice
License
The MIT License (MIT). Please see License File for more information.