Download the PHP package deskola/simple-validator without Composer
On this page you can find all versions of the php package deskola/simple-validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download deskola/simple-validator
More information about deskola/simple-validator
Files in deskola/simple-validator
Package simple-validator
Short Description This is a simple validator library adapted from https://www.phptutorial.net/php-tutorial/
License MIT
Informations about the package simple-validator
Simple Validator
What is it?
A PHP library for sanitizing and validating user inputs. This library is based on https://www.phptutorial.net/ tutorial on how to make a custom input validator form scratch.
1) Installation 2) Supported input types 3) Usage
Installation
PHP versions 7.1 up to PHP 8.1 are currently supported.
The PECL mbstring extension is required.
It is recommended to use composer to install the library.
You can also use any other PSR-4 compliant autoloader.
If you do not use composer, ensure that you also load any dependencies that this project has, such as giggsey/locale.
Supported input types
Below is the list of data type which will be sanitized against. Any data type not in the list will be result into an error
1) string 2) int 3) email 4) float 5) url
Supported Rules
Below are the rule that can be passed against an input
Rule | Rule name | Parameter | Meaning | |
---|---|---|---|---|
required | required | No | The field is set and not empty | |
alphanumeric | alphanumeric | No | The field only contains letters and numbers | |
No | The field is a valid email address | |||
secure | secure | No | The field must have between 8 and 64 characters and contain at least one number, one upper case letter, one lower case letter, and one special character. This rule is for the password field. example (!@#$%^&*+_) | |
min: 3 | min | An integer specifies the minimum length of the field | The length of the field must be greater than or equal to min length, e.g., 3 | |
max: 255 | max | An integer specifies the maximum length of the field | The length of the field must be less than or equal to min length, e.g., 255 | |
same: another_field | same | The name of another field | The field value must be the same as the value of the another_field | |
between: min, max | between | min and max are integers that specify the minimum and maximum length of the field | The length of the field must be between min and max. | |
url | url | No | The field must have a valid url starting with (http/https://) | |
iso:KE | iso | A string value of country ISO Name e.g. KE (for Kenya) | This library also utilises giggsey library to validate phone number based on a country ISO Name | |
options:1,2 | options | comma separated list of items being validated against | ||