Download the PHP package trueifnotfalse/lumen-strict-types-validation without Composer
On this page you can find all versions of the php package trueifnotfalse/lumen-strict-types-validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download trueifnotfalse/lumen-strict-types-validation
More information about trueifnotfalse/lumen-strict-types-validation
Files in trueifnotfalse/lumen-strict-types-validation
Package lumen-strict-types-validation
Short Description A validator for lumen to require strict types in form request data
License MIT
Informations about the package lumen-strict-types-validation
Strict Types Form Request Validation
Ensures incoming form request data is of a certain datatype.
About
While Lumen includes many useful validation rules out of the box, it lacks the ability to validate data type as well
as content type. There have been a couple
complaints about this over the years, but due to the versatile nature of
Laravel, it doesn't seem likely that validation rules such as integer
or boolean
will begin validating that the data
is actually of the desired type.
This package provides a way for you to require the incoming data to be of a given type, such as int
, bool
, float
, etc.
Installation
Pre Requisites
- Lumen v8+
- PHP 7.4+
Install with Composer
Add to bootstrap/app.php
and register the Service Provider.
Usage
When constructing validation rules, simply add type-<desired type>
to the validation rules string/array.
Failure Messages
The failure message format is:
Where attribute
is the attribute being validated (id
from the above example) and type
is the desired type to validate
against (int
in the above example).
If the above example failed, we would receive this message: