Download the PHP package limoncello-php/validation without Composer
On this page you can find all versions of the php package limoncello-php/validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download limoncello-php/validation
More information about limoncello-php/validation
Files in limoncello-php/validation
Package validation
Short Description Validation framework.
License Apache-2.0
Homepage https://github.com/limoncello-php/framework/tree/master/components/Validation
Informations about the package validation
This validation library fast, easy to use yet very powerful and flexible solution. Unlike many other libraries it does not try to give you 'validation rules' for all possible cases because those implementations might not fit your requirements and using such libraries is a pain. Instead it provides an extremely simple way of adding custom validation rules.
Also it supports caching of validation rules which makes it very fast. Custom error codes and messages are supported as well. Error messages could be customized/localized and support placeholders
.
Usage sample
Full sample code is here.
As you can see such custom rules as sku
, amount
, deliveryDate
, address1
, address2
and areTermsAccepted
could be perfectly combined with built-in required
and nullable
. It makes the rules reusable in CREATE
and UPDATE
operations where typically inputs are required on creation and optional on update.
How easy to write those rules? Many could be made from built-in ones below (e.g. amount
, address1
, address2
and areTermsAccepted
)
equals
,notEquals
,inValues
,lessThan
,lessOrEquals
,moreThan
,moreOrEquals
,between
,stringLengthBetween
,stringLengthMin
,stringLengthMax
,regexp
,nullable
,stringToBool
,stringToDateTime
,stringToFloat
,stringToInt
,stringArrayToIntArray
,andX
,orX
,ifX
,success
,fail
,required
,enum
,filter
,isArray
,isString
,isBool
,isInt
,isFloat
,isNumeric
,isDateTime
Custom rule such as IsSkuRule
might require quering database and could be added with minimal overhead
When validator is created a developer can pass PSR Container with custom services and have access to this container from validation rules. Thus validation could be easily integrated with application logic.
Sample application
Installation
Note: for message translation PHP-intl is needed.
Issues
Any related issues please send to limoncello.
Testing
All versions of validation with dependencies
limoncello-php/common Version ^0.10.0
php Version >=7.3.0