Download the PHP package crhayes/validation without Composer

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

Laravel Extended Validator

Introduction

This package was created for several purposes:

  1. To ease the creation of validation services - we all know validaton should be moved out of the controller
  2. Provide an easy way to provide context for validations - such as providing a modified set of validation rules for edit vs. create
  3. Provide an easy way to group validations - that is, calling one 'passes()' method to validate multiple models

Installation

Install this package through Composer. Add the following to your composer.json file:

Next, run composer install

Finally, add the service provider and the facade to app/config/app.php.

Validation as a Service

Most Basic Validator

To create a validation service simply extend the base abstract ContextualValidation class and provide an array of rules and messages (messages will override Laravel's default validation messages).

This service is then instantiated and the validation works much the same as Laravel's built-in validation.

Contextual Validation

Providing Contexts

Sometimes you need to have different rules for the same model depending on the context you are using it within. For instance, maybe some fields are mandatory during registration, but may not be when the user is editing their profile.

We can turn our rules array into a multidimensional array, with unique keys for each of our contexts. The default key denotes our default rules, which will be used for every validation. Default rules can be overridden very easily by setting the rule in other contexts.

Let's see how we can use one of the contexts during the creation of a user:

While editing a user, we would do this:

Multiple contexts can be added as well:

Providing Data to Contexts

Sometimes you need to provide data to your rules. For instance, you may have a unique rule on a field, but when editing the record you don't want an error to be thrown when the user submits a form with the value they previously had.

Luckily, we have a way to handle these instances.

Notice that we have set the email field to be unique by default. However, when the users submits an edit form we want to ignore the current user's id. We use the @id placeholder, and then replace that with the desired value:

The method bindReplacement() takes the rule name as the first parameter; the second parameter is an array of bindings, with the key being the placeholder and value being the replacement value.

Grouped Validator

Have you ever had a form submit data that required two different models be created or updated? Validating both models can be a pain, but that's where the GroupedValidator class comes in.

Let's say we posted a form that is going to create a new user and their car; we therefore need to validate both a user and a car model.

We can use validator contexts with grouped validation as well:

We can also mix and match ContextualValidator services and native Laravel Validators:

Adding Custom Complex Validation

Adding complex validation to your validation services is as easy as follows:

All we do is add the method to our validation service, which accepts an instance of , allowing us to utilize Laravel's built-in support for complex validations.


All versions of validation with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
illuminate/support Version ~5.0
illuminate/http Version ~5.0
illuminate/validation Version ~5.0
illuminate/contracts Version ~5.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 crhayes/validation contains the following files

Loading the files please wait ....