Download the PHP package bugarinov/chain-validation without Composer

On this page you can find all versions of the php package bugarinov/chain-validation. 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 chain-validation

Chain Validation

Notice:

The latest build is 0.2.x and is not backwards compatible with 0.1.x versions. See Migration for details.
Alternatively, you can read 0.1.x-README.md for versions 0.1.x.


Chain Validation is a simple PHP library for handling very complex validations that goes beyond checking of data types, format and values of a given data. It uses the Chain of Responsibility design pattern in order to execute each validation in a consecutive manner. The execution will stop once an error occured during the validation process within a link. You can alter the data as it goes through the chain, depending on your requirements.


Usage

Defining and executing validations

Usage is simple. First, group your validations by purpose/relevance and create a new class for each validation group which extends the AbstractLink class.

You can run the validations using the ChainValidation class. The chain process each validation in exact order or in First in, First out manner.

Catching errors

To know whether an error occured or not, you can use the hasError() function of the ChainValidation class and get the error message using the getErrorMessage() function after the validation execution. You can get the corresponding error code using the getErrorCode() function.

If the chain validation succeeds, it will return the validated data, otherwise it will return null.

Errors with a body

There are instances where errors messages are not enough, especially on front-end applications that highlight specific errors on their UI. Hence, a new parameter was added to the constructor of the ResultFailed class in order to pass the this data to the chain.

The error data can be obtained through the getErrorBody() function of the ChainValidation class and LinkInterface implementations.


Migration from 0.1.x to 0.2.x

In order to migrate from 0.1.x to 0.2.x, you just need to replace the execute function on each link with the evaluate function.

From v0.1.x

to v0.2.x


Tests

Run the tests using composer test.

Tests with mocking of Link's evaluate function are added.


All versions of chain-validation with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2 || ^8.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 bugarinov/chain-validation contains the following files

Loading the files please wait ....