Download the PHP package experience/validation without Composer

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

Overview

This package makes it easy to implement custom validation for any given array of data in your application. It also solves a common problem whereby the validation rules for a "create" action differ to those for an "update" action.

For example, let's say we need to validate some "user account" data, both at the point of registration, and if the user chooses to modify their account at a later date. In Laravel, our (partial) validation rules might look something like this:

That is, the value of the username field must be unique within the users table.

This is fine for account creation, but if the user updates his account without changing his username, the above validation rules will fail. The current users table already contains the given username, and the validation rules don't care that it belongs to the user being validated.

In Laravel, we deal with this problem by telling the validator to ignore the id of the current user, so our rules now look like this:

The Validation package solves this problem by separating the "create" and "update" validation rules, and allowing you to use a {key} placeholder in your rules. Continuing with the above example, our validation rules now look like this:

More detailed implementation examples are provided in the "Usage" section, below.

Installation

Install the package via Composer, as follows:

If you're using Laravel, add the service provider to the providers array in your app/config/app.php file, as follows:

Usage

Let's assume you need to validate a registration form. First, create a custom "validator" class containing the necessary "create" and "update" rules. For example:

Next, inject an instance of your custom validator class into your controller, or wherever you perform your validation:

If validation passes, the validate method returns true. If validation fails, the validate method throws a ValidationException exception. You can catch the exception in your controller (as in the above example), or handle it globally in global.php if you prefer.

Create a dedicated class for each set of data you wish to validate. For example, if your newly-registered users can log in to your site, you'll probably want a SessionValidator:

As before, inject an instance of this validator class into your controller or service, and call the appropriate "validate" method:

Credits

This package was heavily influenced by the Laracasts Validation package. Whilst all the code was written from scratch, I owe a considerable debt of gratitude to Jeffrey Way for the general approach, and for his excellent tutorials at Laracasts.

Laracasts is hands-down the best learning resource available to PHP programmers (not just Laravel enthusiasts). If you're not already a subscriber, you should be.


All versions of validation with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/support Version 4.2.*
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 experience/validation contains the following files

Loading the files please wait ....