Download the PHP package iulyanp/flex-validator without Composer

On this page you can find all versions of the php package iulyanp/flex-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 flex-validator

Flex Validator

Latest Stable Version Total Downloads License composer.lock available

A simple validator based on Respect Validation library, that provides an easy way to customize the error messages.

Installation

If you have composer installed globally you can run:

or you can go with:

Usage

FlexValidator can validate simple input:

For our little example the getErrors() will return something like this:

But you can also validate arrays like this:

`

The getErrors method will return an array with all breaking validation rules:

Validation methods

Currently you can validate simple values and multidimensional arrays.

The validate method is a shortcut also for the array method which will validate multidimensional arrays.

Disable named rules

As we saw in above the examples the error messages had the key of the errors array as the name of the broken rule: alnum, length.

We can disable this with a simple call of the disableRulesName() method on the FlexValidator.

Use dot error keys

Also the errors array can be returned with dot keys.

You can also use the dot keys with disabled rule names together.

Error groups

Sometime when we validate an array of data maybe we want to wrap the error messages in a group. With FlexValidator we can do this in two ways: global group and specific group.

Specific group

First let's take a look on how we can specify a specific group on a specific array key.

As you can see the field username was wrapped in a group login.

Global group

The global group will be applied only on the fields that don't have a specific group set. To specify a global group we can pass the third argument to the validate method.

Custom error messages

Almost all the time when we use a validation library we want to overwrite the default error messages. In the next steps we can see how FlexValidator made this objective very clean and easy to use.

Overwrite default error messages from RespectValidation

We can set the default error messages passing an array with the messages for each respect validation rule.

Custom error messages globally for an entire set of data

We can go further and use custom error messages globally when we validate a set of data by passing the array with error messages as the fourth argument to the validate method.

Custom error messages on specific value of an array

If we want to use a custom error message only for a specific field we can do so by specifying the messages key as an array with all the custom error messages. Here is an example.

As you can see the error message from the name field is taken from the fourth argument of the validate method and the error messages for the phone number are taken from the messages array.


All versions of flex-validator with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0
respect/validation Version ^1.1
symfony/options-resolver Version ^2.8
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 iulyanp/flex-validator contains the following files

Loading the files please wait ....