default
[ class tree: default ] [ index: default ] [ all elements ]

Class: HTML_QuickForm_RuleRegistry

Source Location: /pear/HTML/QuickForm/RuleRegistry.php

Class Overview


Registers rule objects and uses them for validation


Methods



Class Details

[line 27]
Registers rule objects and uses them for validation



[ Top ]


Class Methods


static method singleton [line 47]

static object Reference &singleton( )

Returns a singleton of HTML_QuickForm_RuleRegistry

Usually, only one RuleRegistry object is needed, this is the reason why it is recommended to use this method to get the validation object.




Tags:

return:  to the HTML_QuickForm_RuleRegistry singleton
access:  public


[ Top ]

method getRule [line 110]

object &getRule( string $ruleName)

Returns a reference to the requested rule object



Tags:

access:  public


Parameters:

string   $ruleName   Name of the requested rule

[ Top ]

method getValidationScript [line 161]

string getValidationScript( mixed &$element, string $elementName, array $ruleData)

Returns the validation test in javascript code



Tags:

return:  JavaScript for the rule
access:  public


Parameters:

mixed   &$element   Element(s) the rule applies to
string   $elementName   Element name, in case $element is not array
array   $ruleData   Rule data

[ Top ]

method registerRule [line 77]

void registerRule( string $ruleName, string $type, string $data1, [string $data2 = null])

Registers a new validation rule

In order to use a custom rule in your form, you need to register it first. For regular expressions, one can directly use the 'regex' type rule in addRule(), this is faster than registering the rule.

Functions and methods can be registered. Use the 'function' type. When registering a method, specify the class name as second parameter.

You can also register an HTML_QuickForm_Rule subclass with its own validate() method.




Tags:

access:  public


Parameters:

string   $ruleName   Name of validation rule
string   $type   Either: 'regex', 'function' or null
string   $data1   Name of function, regular expression or HTML_QuickForm_Rule object class name
string   $data2   Object parent of above function or HTML_QuickForm_Rule file path

[ Top ]

method validate [line 135]

mixed validate( string $ruleName, mixed $values, [mixed $options = null], [mixed $multiple = false])

Performs validation on the given values



Tags:

return:  true if no error found, int of valid values (when an array of values is given) or false if error
access:  public


Parameters:

string   $ruleName   Name of the rule to be used
mixed   $values   Can be a scalar or an array of values to be validated
mixed   $options   Options used by the rule
mixed   $multiple   Whether to validate an array of values altogether

[ Top ]


Documentation generated on Sun, 08 Jan 2012 17:51:59 +0100 by phpDocumentor 1.4.3