Sitellite Application Framework
Class Tree         Index         All Elements

Class: MailFormRule

Source Location: Program_Root/MailForm/Rule.php

Class Overview


Handles validation of form fields for the MailForm package.


Author(s)

Version

  • 2.0, 2002-10-12, $Id: Rule.php,v 1.4 2007/01/14 22:10:43 lux Exp $

Copyright

  • Copyright (C) 2001-2003, Simian Systems Inc.

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 98]
Handles validation of form fields for the MailForm package.

Rule Format:

type "value"

Validation Rules:

  • is "value"
  • contains "some value"
  • regex "some regex"
  • equals "anotherfield"
  • empty
  • length "6+" (eg: 6, 6+, 6-12, 12-)
  • gt "value"
  • ge "value"
  • lt "value"
  • le "value"
  • func "func_name" (or function "func_name")
  • unique "dbtablename.columnname"
  • exists "path/to/directory"
  • numeric
  • email
  • header
Note: Any rule may be negated by preceeding it with a 'not', for example:
  • not empty
  • not contains "some value"
New in 1.2:
  • Added a 'unique' rule, which compares the value against a specified field in a database table.
  • Fixed a bug in the 'length' rule evaluation.
New in 1.4:
  • Added 'exists' and 'not exists' rules, which checks if the value given exists (or doesn't) as a file name in the path provided by the rule.
New in 1.6:
  • Abstracted 'not empty' and 'not exists' so that 'not' now negates any rule, and 'empty' and 'exists' are ordinary rules now. This required the addition of two new methods, _validate(), and _validateNegated(), and a new $negated property.
New in 1.8:
  • Added warning notices when rules fail the syntax parser.
  • Added new rule type "numeric", which checks the data type of the value to see whether it is a valid number or not.
New in 2.0:
  • New rules: 'email' and 'header' which help prevent form abuse by spammers. 'email' checks that it is a valid email, and 'header' checks that there are no newlines in the field so that it can't pass extra headers to your mail() function.

1 <?php
2
3 $widget = new MF_Widget ('name');
4 $widget->addRule ('is "foo"', 'You must enter "foo" to pass!');
5
6 // note: MailFormRule is never accessed directly.
7
8 ? >




Tags:

access:  public
version:  2.0, 2002-10-12, $Id: Rule.php,v 1.4 2007/01/14 22:10:43 lux Exp $
license:  http://www.sitellite.org/index/license
copyright:  Copyright (C) 2001-2003, Simian Systems Inc.
author:  John Luxford <mailto:lux@simian.ca>


[ Top ]


Class Variables

$msg =

[line 121]

The error message for this rule.



Tags:

access:  public

Type:   mixed


[ Top ]

$name =

[line 113]

The name of the widget.



Tags:

access:  public

Type:   mixed


[ Top ]

$negated =  false

[line 148]

If a 'not' is present at the start of the rule, this will be set to true, otherwise false.



Tags:

access:  public

Type:   mixed


[ Top ]

$rule =

[line 105]

The original unmodified rule definition.



Tags:

access:  public

Type:   mixed


[ Top ]

$type =

[line 130]

The rule type. Can be 'is', 'contains', 'regex', 'not empty', 'equals', 'length', 'gt', 'ge', 'lt', 'le', or 'func'.



Tags:

access:  public

Type:   mixed


[ Top ]

$value =

[line 139]

The rule value. This corresponds to the part of the rule in double quotes (ie. type "value").



Tags:

access:  public

Type:   mixed


[ Top ]



Class Methods


constructor MailFormRule [line 159]

MailFormRule MailFormRule( string $rule, string $name, [string $msg = ''])

Constructor Method.



Tags:

access:  public


Parameters:

string   $rule  
string   $name  
string   $msg  

[ Top ]

method parseRuleStatement [line 177]

void parseRuleStatement( string $rule)

Parses the original rule into the $type and $value properties.



Tags:

access:  public


Parameters:

string   $rule  

[ Top ]

method validate [line 204]

boolean validate( string $value, object $form, object $cgi)

Validates the value given against itself. Returns false on failure and true on success.



Tags:

access:  public


Parameters:

string   $value  
object   $form  
object   $cgi  

[ Top ]

method _validate [line 223]

boolean _validate( string $value, object $form, object $cgi)

Validates the value given against itself. Returns false on failure and true on success.



Tags:

access:  public


Parameters:

string   $value  
object   $form  
object   $cgi  

[ Top ]

method _validateNegated [line 324]

boolean _validateNegated( string $value, object $form, object $cgi)

Validates the value given against itself. Returns false on failure and true on success.



Tags:

access:  public


Parameters:

string   $value  
object   $form  
object   $cgi  

[ Top ]


Copyright © 2007, SIMIAN systems Inc.
All rights reserved. Privacy policy
Documentation generated on Tue, 13 Feb 2007 17:18:58 -0600 by Sitellite AppDoc and phpDocumentor 1.2.2