Download the PHP package madesimple/php-form-validator without Composer

On this page you can find all versions of the php package madesimple/php-form-validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-form-validator

php-form-validator

PHPUnit

Simple, extendable form validator for multi-dimensional forms

Installation

PHP Form Validator is available on Packagist (using semantic versioning), and installation via Composer is the recommended way to install. Just add this line to your composer.json file:

or run:

Validation Rules

Validation rules are an associative array of dot notation field names in the input array to a pipe separated string of rules. The asterisk, *, can be use in the dot notation as a wildcard. For example, a set of rules could look like this:

The following are all the validation rules that this library provides:

Rule Name Keyword Parameters Description
Present present The field must be present but can have any value including null.
Required required The field must be present and cannot be null (can be an empty string).
Required If required-if field(,value)+ The field is required if the specified field(s) and the specified value(s).
Required With required-with field The field is required if the other field is not null.
Required With All required-with-all field(,field)* The field is required if all of the other fields are not null.
Required With Any required-with-any field(,field)* The field is required if any of the other fields are not null.
Required Without required-without field The field is required if the other field is null.
Equals equals field The field's value must equals the other specified field's value.
Not Equals not-equals field The field's value must not equal the other specified field's value.
Identical identical field The field's value must be identical the other specified field's value.
Not Identical not-identical field The field's value must not be identical the other specified field's value.
In in value(,value)* The field must equal one of the specified options.
Not In not-in value(,value)* The field must not equal one of the specified options.
Contains contains value(,value)* The field should be an array and must contain all the specified options (may contain other values not listed).
Contains Only contains-only value(,value)* The field should be an array and must contain only the specified options.
Minimum Array Count min-arr-count int The field should be an array and must have an array_count of at least the specified value.
Maximum Array Count max-arr-count int The field should be an array and must have an array_count of at most the specified value.
Minimum min int The field should be numeric and must be at least the specified value.
Maximum max int The field should be numeric and must be at most the specified value.
Greater Than greater-than field The field should be numeric and must have a value greater than the other field.
Less Than less-than field The field should be numeric and must have a value less than the other field.
Alpha alpha The field must only contain alphabetic characters.
Alpha Numeric alpha-numeric The field must only contain alphabetic and numerical characters.
Minimum String Length min-str-len int The field should be string and must have a strlen of at least the specified value.
Maximum String Length max-str-len int The field should be a string and must have a strlen of at most the specified value.
String Length str-len int The field should be a string and must have a strlen of exactly the specified value.
Human Name human-name The field must be a valid human name.
Is: ... is type The field must be of the specified basic PHP type. There must be a corresponding is_<type> method.
Email email The field must be a valid email address
Date date (format)? The field must be a valid date in the specified format (defaults to 'Y-m-d').
URL url The field must be a valid URL.
UUID uuid The field must be a valid UUID (\universally unique identifier).
Card Number card-number The field must be a valid card number.
Regex regex regex pattern The field must match the regex pattern.
Not Regex not-regex regex pattern The field must not match the regex pattern.

Adding Extra Rules

Extra rules can be added to the validator to extend its functionality to provide specific rules for your project. If you believe your rule should be added to the core library please submit a pull request. To add your extra rule you must call both addRule and setRuleMessage.

Simple extra rule

For example, if you wanted to add a rule that would validate that a timezone was valid:

Extra rule with parameters

For example, if you wanted to add a rule that would validate that an identifier existed in your database:

Another example, if you wanted to do a complex validation of a sub-array:

Validation Rules

Present

The field must be present but can have any value including null.

Required

The field must be present and cannot be null (can be an empty string).

Required If

The field is required if the specified field(s) and the specified value(s).

Required With

The field is required if the other field is not null.

Required With All

The field is required if all the other fields are not null.

Required With Any

The field is required if any of the other fields are not null.

Required Without

The field is required if the other field is null.

Equals

The field's value must be equal to the other specified field's value.

Not Equals

The field's value must not equal the other specified field's value.

Identical

The field's value must be identical the other specified field's value.

Not Identical

The field's value must not be identical the other specified field's value.

In

The field must equal one of the specified options.

Not In

The field must not equal one of the specified options.

Contains

The field should be an array and must contain all the specified options (may contain other values not listed).

Contains Only

The field should be an array and must contain only the specified options.

Min Array Count

The field should be an array and must have an array_count of at least the specified value.

Max Array Count

The field should be an array and must have an array_count of at most the specified value.

Min

The field should be numeric and must be at least the specified value.

Max

The field should be numeric and must be at most the specified value.

Greater Than

The field should be numeric and must have a value greater than the other field.

Less Than

The field should be numeric and must have a value less than the other field.

Alpha

The field must only contain alphabetic characters.

Alpha Numeric

The field must only contain alphabetic and numerical characters.

Min String Length

The field should be string and must have a strlen of at least the specified value.

Max String Length

The field should be a string and must have a strlen of at most the specified value.

String Length

The field should be a string and must have a strlen of exactly the specified value.

Human Name

The field must be a valid human name.

Is ...

The field must be of the specified basic PHP type. There must be a corresponding is_<type> method.

Email

The field must be a valid email address

Date

The field must be a valid date in the specified format (defaults to 'Y-m-d').

URL

The field must be a valid URL.

UUID

The field must be a valid UUID (\universally unique identifier).

Card Number

The field must be a valid card number. See http://stackoverflow.com/questions/174730/what-is-the-best-way-to-validate-a-credit-card-in-php for more details.

Regex

The field must match the regex pattern provided as parameter. Specify rules in an array when using this rule, especially when the regex expression contains a | character. See https://www.php.net/preg_match for nore details.

Not Regex

The field must not match the regex pattern provided as parameter. Specify rules in an array when using this rule, especially when the regex expression contains a | character. See https://www.php.net/preg_match for nore details.


All versions of php-form-validator with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
madesimple/php-arrays Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package madesimple/php-form-validator contains the following files

Loading the files please wait ....