Download the PHP package simple-as-fuck/php-validator without Composer
On this page you can find all versions of the php package simple-as-fuck/php-validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-validator
Simple as fuck / Php Validator
Validator for php variables with intuitive rule chain, put inside mixed and you in the end get requested type.
Installation
Support
If any PHP platform requirements in composer.json ends with security support, consider package version as unsupported except last version.
Usage
This validation can be applied into any php variable and is appropriately usable for json decoded data. All rules have declared types for next rule in chain so not look for any rules list, your IDE should hint you available rules and rule chain is designed for preventing redundant rules or rule combination which do not make sense.
Validation exception type changing
You can change exception type throw from rule chain while validation failed by inject yours exception factory.
If you want throw some HTTP exception for validation http request beware of this validator is not suitable for validation user inputs.
First: validator fail in first unsuccessful rule in nested structure and throw only one exception even if there can be more validation fails.
Second: validator throw highly generated messages which can be for user unreadable and translation support is not in plan, for us developers messages should be fine.
Third: realise than we write in PHP server side application so the app should return data in some API format and view data should some weird javascript, native or mobile client app. Yes I know than even pc games are rendered in cloud but client pc has also some computing power and if client logic and html is rendered on server is only wasting of its power.
Customization
User defined rule
You can create your rule and put it in the end of rule chain and this allow you to run some yours validation.
If you are validating something what is widely standardized, consider contribute into rule chain, for more nicely writing it or share some rule with others.
User class rule
Validator rule chain always return some specific type so generic object is not in option. You are able to convert object into some class with validated structure.