Documentation

ClosureValidationRule extends BaseRule
in package

This rule tests values against a provided function that checks whether the data it will receive later is valid.

Tags
author

César de la Cal cesar@magic3w.com

Table of Contents

$closure  : Closure
The function used to evaluate the value. If this function returns true, the application may continue, otherwise the data it received was invalid.
$extendedMessage  : string
Additional information given to the user in case the validation did not succeed. This message can hold additional infos on how to solve the error.
$message  : string
A message the validation error generated by this object should carry to give the end user information about the reason his input was rejected.
__construct()  : mixed
Creates a rule to test a value against a closure. If the closure returns true, the test is considered succesful and the application can continue.
getExtendedMessage()  : mixed
getMessage()  : mixed
test()  : ValidationError|bool
Tests a value with this validation rule. Returns the errors detected for this element or boolean false on no errors.

Properties

$closure

The function used to evaluate the value. If this function returns true, the application may continue, otherwise the data it received was invalid.

private Closure $closure

$extendedMessage

Additional information given to the user in case the validation did not succeed. This message can hold additional infos on how to solve the error.

private string $extendedMessage

$message

A message the validation error generated by this object should carry to give the end user information about the reason his input was rejected.

private string $message

Methods

__construct()

Creates a rule to test a value against a closure. If the closure returns true, the test is considered succesful and the application can continue.

public __construct(Closure $closure, string $message[, string $extendedMessage = '' ]) : mixed
Parameters
$closure : Closure
$message : string
$extendedMessage : string = ''
Return values
mixed

getExtendedMessage()

public getExtendedMessage() : mixed
Return values
mixed

getMessage()

public getMessage() : mixed
Return values
mixed

Search results