Abstract implementation of range comparsion rules

category Formagic
package Rule
subpackage RangeComparsion
author Florian Sonnenburg
copyright Copyright (c) 2007-2011 Florian Sonnenburg
version $Id: Abstract.php 169 2012-05-06 20:16:16Z meweasle $

 Methods

Constructor

__construct(array $arguments) 
Inherited

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

see \self::_init()
inherited_from \Formagic_Rule_Abstract::__construct()

Parameters

$arguments

array

The rule options.

Returns translated error message of rule

getMessage() : string
Inherited

inherited_from \Formagic_Rule_Abstract::getMessage()

Returns

stringMessage string

Returns rule type identification string.

getName() : string
Inherited

inherited_from \Formagic_Rule_Abstract::getName()

Returns

stringThe rule name

Not supported by range comparison rules.

setMessage(string $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.

Parameters

$message

string

New message string

Exceptions

\Formagic_Exception

Returns

Sets messages array

setMessages(array $messages) : \Formagic_Rule_RangeComparsion_Abstract

Parameters

$messages

array

Array of messages

Returns

Performs rule check

validate(string $value) : boolean

Length rule checks if value is between min and max length. The validation method depends on $this->_type.

Parameters

$value

string

The item to checked

Returns

booleanThe validation result

Evaluate between range (including limits).

_execBetween(integer $range) : boolean

Parameters

$range

integer

Range value

Returns

booleanEvaluation result

Evaluate maximum range (lessers or equals).

_execMax(integer $range) : boolean

Parameters

$range

integer

Upper limit

Returns

booleanEvaluation result

Evaluate minimum range (greater or equals).

_execMin(integer $range) : boolean

Parameters

$range

integer

Lower limit

Returns

booleanEvaluation result

Returns a translates message string.

_getMessage(string $key) : string

Parameters

$key

string

Message type

Returns

stringTranslated filled message

Returns range check value.

_getRange(string $value) : mixed

Parameters

$value

string

Item value

Returns

mixedCheck range value

Allows subclass initialization.

_init(array $arguments) : void

Allowed options for this rule are:

(integer)min:
Minimal length to be checked (optional, defaults to 0)
(integer)max:
Maximal length to be checked (optional, defaults to 0)

Will throw an exception, if neither "min" nor "max" option provided.

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 $value) : boolean
Inherited

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

inherited_from \Formagic_Rule_Abstract::_isNoUserValue()

Parameters

$value

\$value

mixed Value to be checked

Returns

boolean

 Properties

 

The maximal length

$_max : integer

 

Message string

$_message : string
Inherited

inherited_from \Formagic_Rule_Abstract::$$_message
 

Array of messages

$_messages : array

 

The minimal length

$_min : integer

 

Rule type identifier.

$_name : string
Inherited

inherited_from \Formagic_Rule_Abstract::$$_name