GithubHelp home page GithubHelp logo

tenga / laravel-validator-with-labels Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 102 KB

Library that extends the default Laravel 3 validator implementation with CodeIgnitery passable attribute labels.

PHP 100.00%

laravel-validator-with-labels's Introduction

Extended Laravel 3 validator with labels

Library that extends the default Laravel validator implementation with CodeIgniter-like passable attribute labels.

Installation

Dump it into application/libraries folder and comment out the default alias for Laravel validator in the application/config/application.php

Usage

Manually passing labels, these will take priority over language/xx/validation defined ones and the ones generated from the name attribute:

// Defining our rules as usual
$rules = array(
	'email' => 'required|email',
	'full_name' => 'required'
);

// Defining our labels for the validator to use
$attribute_labels = array(
	'email' => 'E-mail address',
	'full_name' => 'Your full name'
);

// Make the validator as usual and pass some labels
$validation = Validator::make(Input::all(), $rules)->with_labels($attribute_labels);

Calling with_labels() multiple times merges the new labels with the ones already set before and updates in case label keys match.

You can access all defined labels by accessing the attribute_labels property on the Validator object:

$validation = Validator::make(Input::all(), $rules)->with_labels($attribute_labels);
$all_labels = $validation->attribute_labels;

And if you need to clear the labels you can clear the labels by using the clear_labels() method

$validation = Validator::make(Input::all(), $rules)->with_labels($attribute_labels);

// For some reason we have changed our mind
$validation->clear_labels();

laravel-validator-with-labels's People

Contributors

tenga avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.