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

Class: HTML_QuickForm_RuleRegistry

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

Class Overview


Registers rule objects and uses them for validation


Author(s):

Version:

  • Release: 3.2.14

Methods


Inherited Variables

Inherited Methods


Class Details

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


[ Top ]


Method Detail

getRule   [line 120]

HTML_QuickForm_Rule &getRule( string $ruleName)

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

Parameters:

string   $ruleName   —  Name of the requested rule

[ Top ]

getValidationScript   [line 172]

string getValidationScript( array|HTML_QuickForm_element &$element, string $elementName, array $ruleData)

Returns the validation test in javascript code
  • Return: JavaScript for the rule
  • Access: public

Parameters:

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

[ Top ]

registerRule   [line 87]

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

HTML_QuickForm_RuleRegistry &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.

  • Access: public

[ Top ]

validate   [line 145]

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 15:59:48 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.