ZenMagick 0.9.6


org.zenmagick.validation.ZMRule

Class ZMRule

ZMObject
|
+--ZMRule

public abstract class ZMRule
extends ZMObject

Base class for validation rules.

Author:
DerManoMann
Version:
$Id: ZMRule.php 2158 2009-04-16 01:34:04Z dermanomann $

Fields inherited from org.zenmagick.ZMObject
properties_
Constructor Summary

ZMRule(string name, string defaultMsg, string msg)

Create new validation rule.

Method Summary
string

getDefaultMsg()

Get the default error message.

string

getErrorMsg()

Return an appropriate error message.

string

getJSName()

Get the form field name this rule is validating.

string

getMsg()

Get the custom error message.

string

getName()

Get the parameter name this rule is validating.

string

toJSString()

Create JS validation call.

boolean

validate(array req)

Validate the given request data.

Methods inherited from org.zenmagick.ZMObject
attachMethod, get, getAttachedMethods, getPropertyNames, set, singleton

Constructor Detail

ZMRule

public ZMRule(string name, string defaultMsg, string msg)

Create new validation rule.

Parameters:
name - The field name.
defaultMsg - The default error message.
msg - Optional custom error message.

Method Detail

getDefaultMsg

public string getDefaultMsg()

Get the default error message.

Returns:
The default error message.

getErrorMsg

public string getErrorMsg()

Return an appropriate error message.

Returns:
Localized error message.

getJSName

public string getJSName()

Get the form field name this rule is validating.

This might be different in case of checkboxes or other input fields that allow multiple values. In that case PPH requires to to suffix form field names with '[]'. However, the request parameter will not have this suffix (rather being an array instead of a string).

Returns:
The form field name this rule is testing.

getMsg

public string getMsg()

Get the custom error message.

Returns:
The custom error message.

getName

public string getName()

Get the parameter name this rule is validating.

Returns:
The name of the request parameter (GET/POST) this rule is testing.

toJSString

public string toJSString()

Create JS validation call.

Returns:
Formatted JavaScript .

validate

public boolean validate(array req)

Validate the given request data.

Parameters:
req - The request data.
Returns:
true if the value for $name is valid, false if not.

ZenMagick 0.9.6