Download the PHP package pnhs/form_validator without Composer
On this page you can find all versions of the php package pnhs/form_validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pnhs/form_validator
More information about pnhs/form_validator
Files in pnhs/form_validator
Package form_validator
Short Description Validates forms and other strings
License MIT
Homepage http://github.com/seraf-im/form-validator
Informations about the package form_validator
Form Validator 
English | Portuguese
Form Validator is an open source library for validating data received from users by forms or other means. The focus is to be simple and have an architecture compatible with the latest features of PHP.
We provide an example using "Form URL Encoded" (submission via simple HTML form) and a JSON example (submission via VUE-JS), we suggest you test both examples by doing Installation for testing, logo bellow
Help the Project to continue, donate a coffee!
or pix for brazilians: [email protected]
Installation for testing
To test before including it in your project, open the terminal, prompt or powershell and run the commands below:
Remembering that it is necessary that you have previously installed PHP and GIT.
Installation in your project
Composer
If you already know Composer (which is highly recommended), simply open the terminal, prompt or powershell in your project folder and type:
How to use
That's the best part. It couldn't be simpler, see a basic example:
Yes, just that! Just use the rules according to your need, if you wish you can contribute to the project by adding new rules. In the samples folder there are examples of using all the rules.
Supported Rules
Currently the Form Validator works with the following rules, remember you can always add more:
Rule | Information | Details |
---|---|---|
array | ||
date | Y-m-d standard date format | If your date has another pattern for example d/m/Y, just use this way "date:d/m/Y". The return always follows the Y-m-d pattern |
datetime | Y-m-d H:i:s standard date format | If your date has another pattern for example d/m/Y H:i:s, just use this way "date:d/m/Y H:i:s". The return always follows the pattern Y-m-d H:i:s |
decimal | 2 standard decimal places | If you want to use a number of decimal places other than 2, use "decimal: x" , changing x to the desired number of decimal places. |
exact:x | To define the number of characters, change the x to the desired amount | |
integer | ||
max_len:x | ||
min_len:x | ||
For min_len and max_len , change x to the desired number of characters | ||
no_empty | ||
numeric | ||
required | It can be empty, if you want the field to be required and not empty use both rules | |
string |
Custom error code
You can use the # (hash) after the rule to enter the custom error code if you wish.
Future rules
- username
- Password policy
- Document Validation*
- Phone validation*
*We are looking for the best way to include these rules as they change by document type, state and country.
Contribution
Every contribution is welcome. If you want to add new rules, feel free to explore the code, see how simple it is to integrate any rule into the library.
Translation
Also collaborate by including and correcting translations.
License
- MIT License