2017 © Pedro Peláez
 

library input

Input processing package for Laravel 5

image

nztim/input

Input processing package for Laravel 5

  • Monday, January 15, 2018
  • by nztim
  • Repository
  • 1 Watchers
  • 0 Stars
  • 103 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 5 % Grown

The README.md

Input Processor

Define input filtering, validation rules and type casting all in one place, and ensure that the input array has all the desired keys., (*1)

Installation

composer require nztim/input, (*2)

Usage

Create a Processor class that extends NZTim\Input\BaseProcessor and add overrides as follows:, (*3)

  • protected function rules() - returns an array of Laravel validation rules. This method is abstract so must be implemented.
  • The input data is normalized so that all fields in the rules array are certain to be present, and any other fields are filtered out
  • Note: this means all valid fields must have a rule, even if it's empty.
  • protected function messages() - returns an array of your validation message overrides.
  • protected function casts() - returns an array of fields to typecast.
  • Valid possibilities are bool, int, float, and a callable. E.g. ['age' => 'int', 'subscribe' => 'bool', 'foo' => function($value) { //... }]

Then, to handle form input:, (*4)

  • Inject the Processor class into your controller.
  • The request is used to set the input values.
  • $processor->setInput() and $processor->removeInput() can directly modify the input array as required.
    • Can be used to set input values not in the rules() array.
  • $processor->validate() returns boolean success/failure. Arguments allow you to override/merge rules/messages as needed.
  • $processor->getValidation() returns the validation object, or false if validation was successful.
  • $processor->getInput() returns input casted to desired types, use getInput(false) to return uncasted input.

To handle other situations, inject the Processor class and use $processor->replaceInput($inputArray) to set the entire input array at once., (*5)

The Versions

15/01 2018

dev-master

9999999-dev

Input processing package for Laravel 5

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

15/01 2018

v1.3

1.3.0.0

Input processing package for Laravel 5

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

01/05 2016

v1.2.0

1.2.0.0

Input processing package for Laravel 5

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

26/03 2016

v1.1.0

1.1.0.0

Input processing package for Laravel 5

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

26/03 2016

v1.0.2

1.0.2.0

Input processing package for Laravel 5

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

26/03 2016

v1.0.1

1.0.1.0

Input processing package for Laravel 5

  Sources   Download

MIT

The Requires

 

26/03 2016

v1.0.0

1.0.0.0

Input processing package for Laravel 5

  Sources   Download

MIT

The Requires