FormagicRule abstract superclass

package Formagic\Rule
author Florian Sonnenburg
since 1.0.0 First time introduced

 Methods

Constructor

__construct(array $arguments = array()

The default error message that is displayed if the rule is violated can be overwritten by $errorMessage.

see

Parameters

$arguments

array

The rule options.

Returns translated error message of rule

getMessage() : string

Returns

stringMessage string

Returns rule type identification string.

getName() : string

Returns

stringThe rule name

Sets the error message property.

setMessage(mixed $message) : \Formagic_Rule_Abstract

Usually a rule will have one error message string that is used if the validation fails. If neccessary, Formagic_Rule_Abstract::_errorMessage can hold other variables, eg. an array of error messages for different outcomes of the validation process.

Implements a fluent interface pattern.

see

Parameters

$message

mixed

The error message value.

Returns

\Formagic_Rule_Abstract$this object.

Abstract of main validate method. Returns boolean value of check success.

validate(string $value) : boolean

Subclasses have to implement their behavior here.

Parameters

$value

string

The value to be validated.

Returns

booleanThe rule check result

Allows subclass initialization.

_init(array $arguments) : void

Parameters

$arguments

array

Array of arguments passed to __construct()

Checks if value is not entered by a user or if the field has not been assigned to the form.

_isNoUserValue($value) : boolean

The value 0 (zero) for example could be something the user entered willingly and would be skipped from rule checks when using empty().

Parameters

$value

mixed Value to be checked

Returns

boolean

 Properties

 

Message string

$_message : string

Default

'Please enter a valid value'
 

Rule type identifier.

$_name : string

Default