klapuch/validation

There is no license information available for the latest version (2.6.3) of this package.

Broad variation of validation

2.6.3 2019-01-01 14:11 UTC

This package is auto-updated.

Last update: 2024-03-29 03:19:27 UTC


README

Build Status Build status Coverage Status

Documentation

Installation

composer require klapuch/validation

Usage

Single rule

(new EmptyRule())->satified('abc'); // false
(new EmptyRule())->satified(''); // true
(new EmptyRule())->apply('abc'); // \UnexpectedValueException - 'Subject is not empty'
(new FriendlyRule(new EmptyRule(), 'Not empty!'))->apply('abc'); // \UnexpectedValueException - 'Not empty!'

Chained rule

(new ChainedRule(
	new FriendlyRule(
		new NegateRule(new EmptyRule()),
		'Value can not be empty'
	),
	new LengthRule(10),
	new PassiveRule, // it does nothing
	new EmailRule(),
))->apply('abc');

The above code says that a value can not be empty, length of the value must be exact 10 characters and the value must be email.