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

Class: HTML_QuickForm2_Rule_Regex

Source Location: /HTML_QuickForm2-2.1.0/HTML/QuickForm2/Rule/Regex.php

Class Overview

HTML_QuickForm2_Rule
   |
   --HTML_QuickForm2_Rule_Regex

Validates values using regular expressions


Author(s):

Version:

  • Release: 2.1.0

Methods


Child classes:

HTML_QuickForm2_Rule_NotRegex
Checks that the element's value does not match a regular expression

Inherited Variables

Inherited Methods

Class: HTML_QuickForm2_Rule

HTML_QuickForm2_Rule::__construct()
Class constructor
HTML_QuickForm2_Rule::and_()
Adds a rule to the chain with an "and" operator
HTML_QuickForm2_Rule::getConfig()
Returns the rule's configuration data
HTML_QuickForm2_Rule::getJavascript()
Returns the client-side representation of the Rule
HTML_QuickForm2_Rule::getJavascriptCallback()
Returns the client-side validation callback
HTML_QuickForm2_Rule::getJavascriptTriggers()
Returns IDs of form fields that should trigger "live" Javascript validation
HTML_QuickForm2_Rule::getMessage()
Returns the error message output by the rule
HTML_QuickForm2_Rule::getOwnJavascriptTriggers()
Returns IDs of form fields that should trigger "live" Javascript validation
HTML_QuickForm2_Rule::mergeConfig()
Merges local configuration with that provided for registerRule()
HTML_QuickForm2_Rule::or_()
Adds a rule to the chain with an "or" operator
HTML_QuickForm2_Rule::setConfig()
Sets configuration data for the rule
HTML_QuickForm2_Rule::setMessage()
Sets the error message output by the rule
HTML_QuickForm2_Rule::setOwner()
Sets the element that will be validated by this rule
HTML_QuickForm2_Rule::setOwnerError()
Sets the error message on the owner element
HTML_QuickForm2_Rule::validate()
Performs validation
HTML_QuickForm2_Rule::validateOwner()
Validates the owner element

Class Details

[line 50]
Validates values using regular expressions

The Rule needs one configuration parameter for its work: a Perl-compatible regular expression. This parameter can be passed either to the Rule constructor as local configuration or to HTML_QuickForm2_Factory::registerRule() as global one. As usual, global configuration overrides local one.

The Rule can also validate file uploads, in this case the regular expression is applied to upload's 'name' field.

The Rule considers empty fields (file upload fields with UPLOAD_ERR_NO_FILE) as valid and doesn't try to test them with the regular expression.



[ Top ]


Method Detail

getJavascriptCallback   [line 99]

string getJavascriptCallback( )

Returns the client-side validation callback

For this to work properly, slashes have to be used as regex delimiters. The method takes care of transforming PHP unicode escapes in regexps to JS unicode escapes if using 'u' modifier (see bug #12736)

  • Access: protected

Overridden in child classes as:

HTML_QuickForm2_Rule_NotRegex::getJavascriptCallback()
Returns the client-side validation callback

Overrides HTML_QuickForm2_Rule::getJavascriptCallback() (Returns the client-side validation callback)
[ Top ]

setConfig   [line 79]

HTML_QuickForm2_Rule setConfig( string $config)

Sets the regular expression to validate with
  • Throws: HTML_QuickForm2_InvalidArgumentException if $config is not a string
  • Access: public

Overrides HTML_QuickForm2_Rule::setConfig() (Sets configuration data for the rule)

Parameters:

string   $config   —  Regular expression

[ Top ]

validateOwner   [line 57]

bool validateOwner( )

Validates the owner element
  • Return: whether element's value matches given regular expression
  • Access: protected

Overridden in child classes as:

HTML_QuickForm2_Rule_NotRegex::validateOwner()
Validates the owner element

Overrides HTML_QuickForm2_Rule::validateOwner() (Validates the owner element)
[ Top ]


Documentation generated on Wed, 10 Apr 2019 08:56:10 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.