Download the PHP package omnicode/lara-validation without Composer

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

Build Status Total Downloads Latest Stable Version License

Lara Validation - wrapper for Laravel Validation

Lara Validation is a powerful wrapper for laravel validations (it is influenced by Cakephp 3 validations)

It has the following advantages

Contents

  1. Installation
  2. Quick start
  3. Features
    • Basic example
    • Custom validation message
    • Conditional validation during create and update
    • Conditional validation with callable method
    • Adding existing laravel rules
    • Adding custom rules
    • Stopping On First Validation Failure
    • Sharing rules between different validations
    • Using with form requests
  4. Methods
    • required
    • minLength
    • maxLength
    • email
    • numeric
    • unique

Installation

At composer.json of your Laravel installation, add the following require line:

Run composer update to add the package to your Laravel app.

Quick start

Define simple validator

Use it inside your controller or service layer

Features

LaraValidation has some pre-defined methods, each method has the parameter for providing the field name, possible paramters based on each rule, as well as an optional $when parameter which might a callable function, or a string as create or update. Any laravel validation rules that do not have wrappers can be easily added by add method, which allows also to add custom validation methods as a callable function.

Basic Example

To make the field to be required we can simply write

Custom validation message

Conditional validation during create and update

To make the rule to be applied only when the record is being created or only when it is being updated

Conditional validation with callable method

Use callable method for conditional validation

$input is and object of Illuminate\Support\Fluent that contains the data to be validated.

Adding existing Laravel rules

If the rule does not have a wrapper, but it exists in Laravel, it can be easily added by

Adding custom rules

Using add method custom rules by callable methods can be defined

for the second parameter(in the array), implicit option can be defined as well. More info here

$attribute, $value, $parameters and $validator params of the method are defined here

Stopping On First Validation Failure

For stopping the valudation rules if the given rule fails, use bail or its alias last

in this case if some_field fails to be numeric it will not check for minLength or maxLength rules

Sharing rules between different validations

It might be cases, that it is required to apply different set of validation rules with different scenarios - meanwhile sharing part of the rules:

To validate the data

Existing methods

Here is the list of predefined methods and wrappers

for all methods

required

$name can be either string as the field name or array of fields (however in case of array the same error message will be used for all provided fields)

minLength

$length mininum number of characters to be allowed

maxLength

$length maximum number of characters to be allowed

email

numeric

unique

$params can be either

Important Notice: the field user_id should exist in the validation data

Using with form requests

The rules defined by LaraValidation can be easily used in Form Requests, for that rules and messages methods should be used, which return the list of validation rules in native format and the list of messages respectively.


All versions of lara-validation with dependencies

PHP Build Version
Package Version
Requires laravel/framework Version 5.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 omnicode/lara-validation contains the following files

Loading the files please wait ....