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

Class: HTML_QuickForm_RuleRegistry

Source Location: /HTML_QuickForm-3.2.5/QuickForm/RuleRegistry.php

Class Overview


Registers rule objects and uses them for validation


Methods


Inherited Variables

Inherited Methods


Class Details

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


[ Top ]


Method Detail

getRule   [line 110]

object &getRule( string $ruleName)

Returns a reference to the requested rule object
  • Access: public

Parameters:

string   $ruleName   —  Name of the requested rule

[ Top ]

getValidationScript   [line 161]

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

Returns the validation test in javascript code
  • 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 ]

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.

  • 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 ]

singleton   [line 47]

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.

  • Return: to the HTML_QuickForm_RuleRegistry singleton
  • Access: public

[ Top ]

validate   [line 135]

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

Performs validation on the given values
  • 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 Mon, 11 Mar 2019 14:16:36 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.