Class RegexValidatorRule

Description

a RegexValidatorRule checks a given value against a regular expression

  • version: $Id: RegexValidatorRule.class.php,v 1.6 2007/09/04 20:25:55 adamfranco Exp $
  • license: GNU General Public License (GPL)
  • copyright: Copyright © 2005, Middlebury College

Located in /harmoni/core/utilities/FieldSetValidator/rules/RegexValidatorRule.class.php (line 15)

ValidatorRuleInterface
   |
   --RegexValidatorRule
Direct descendents
Class Description
DottedPairValidatorRule The DottedPairValidatorRule checks to see if a string is of a "module.action" dotted-pair format.
CSSColorValidatorRule a RegexValidatorRule checks a given value against a regular expression
CSSFontFamilyValidatorRule a RegexValidatorRule checks a given value against a regular expression
CSSLengthValidatorRule a RegexValidatorRule checks a given value against a regular expression
CSSLengthValidatorRuleWithOptions a RegexValidatorRule checks a given value against a regular expression
EmailValidatorRule a EmailValidatorRule checks a given value to make sure it is an email address
FieldRequiredValidatorRule a FieldRequiredValidatorRule checks a given value to make sure it is set (not blank)
Variable Summary
mixed $_regex
Method Summary
void RegexValidatorRule (string $regex)
boolean check (mixed $val)
string generateJavaScript ()
object ValidatorRule getRule (string $regex)
object ValidatorRule getRuleByArray (mixed $options, string $regex)
string getRuleKey ()
Variables
mixed $_regex (line 24)

the regular expression that should be used to check the value

  • access: private

Redefined in descendants as:
Methods
Constructor RegexValidatorRule (line 33)

the constructor

  • access: public
void RegexValidatorRule (string $regex)
  • string $regex: the regular expression to be used
check (line 43)

checks a given value against the regular expression defined

  • return: true if the check succeeds, false if it (guess...) fails.
  • access: public
boolean check (mixed $val)
  • mixed $val: the value to check against the regex

Redefinition of:
ValidatorRuleInterface::check()
checks a given value against the rule contained within the class
generateJavaScript (line 95)

Returns a block of javascript code defining a function like so:

function(element) { return el.value.match(/\w+/); }

  • access: public
string generateJavaScript ()
getRegularExpression (line 53)

gets the regular expression

  • return: the regular expression
  • access: public
string getRegularExpression ()
getRule (line 71)

This is a static method to return an already-created instance of a validator rule. There are at most about a hundred unique rule objects in use durring any given execution cycle, but rule objects are instantiated hundreds of thousands of times.

This method follows a modified Singleton pattern.

  • since: 3/28/05
  • static:
  • access: public
object ValidatorRule getRule (string $regex)
  • string $regex

Redefinition of:
ValidatorRuleInterface::getRule()
This is a static method to return an already-created instance of a validator rule. There are at most about a hundred unique rule objects in use durring any given execution cycle, but rule objects are instantiated hundreds of thousands of times.

Redefined in descendants as:
  • DottedPairValidatorRule::getRule() : This is a static method to return an already-created instance of a validator rule. There are at most about a hundred unique rule objects in use durring any given execution cycle, but rule objects are instantiated hundreds of thousands of times.
  • CSSColorValidatorRule::getRule() : This is a static method to return an already-created instance of a validator rule. There are at most about a hundred unique rule objects in use durring any given execution cycle, but rule objects are instantiated hundreds of thousands of times.
  • CSSFontFamilyValidatorRule::getRule() : This is a static method to return an already-created instance of a validator rule. There are at most about a hundred unique rule objects in use durring any given execution cycle, but rule objects are instantiated hundreds of thousands of times.
  • CSSLengthValidatorRule::getRule() : This is a static method to return an already-created instance of a validator rule. There are at most about a hundred unique rule objects in use durring any given execution cycle, but rule objects are instantiated hundreds of thousands of times.
  • CSSLengthValidatorRuleWithOptions::getRule() : Note: this class takes a parameter and may have several instantiations.
  • EmailValidatorRule::getRule() : This is a static method to return an already-created instance of a validator rule. There are at most about a hundred unique rule objects in use durring any given execution cycle, but rule objects are instantiated hundreds of thousands of times.
  • FieldRequiredValidatorRule::getRule() : This is a static method to return an already-created instance of a validator rule. There are at most about a hundred unique rule objects in use durring any given execution cycle, but rule objects are instantiated hundreds of thousands of times.
getRuleByArray (line 119)

This is a static method to return an already-created instance of a validator rule. There are at most about a hundred unique rule objects in use durring any given execution cycle, but rule objects are instantiated hundreds of thousands of times.

This one genrates a regular expression from an array of regular expressions. The whole string must match.

This method follows a modified Singleton pattern.

  • since: 3/28/05
  • static:
  • access: public
object ValidatorRule getRuleByArray (mixed $options, string $regex)
  • string $regex
getRuleKey (line 156)

Return a key that can be used to identify this Rule for caching purposes.

If this rule takes no arguments, the class name should be sufficient. otherwise, append the arguments.

This method should only be called by ValidatorRules.

  • since: 3/29/05
  • access: protected
string getRuleKey ()

Redefinition of:
ValidatorRuleInterface::getRuleKey()
Return a key that can be used to identify this Rule for caching purposes.

Inherited Methods

Inherited From ValidatorRuleInterface

ValidatorRuleInterface::check()
ValidatorRuleInterface::getRule()
ValidatorRuleInterface::getRuleKey()

Documentation generated on Wed, 19 Sep 2007 10:25:55 -0400 by phpDocumentor 1.3.0RC3