ZenMagick 0.9.8


org.zenmagick.mvc.validation.ZMRule
\mvc\validation\ZMRule.php at line 31

Class ZMRule

ZMObject
└─ZMRule

public abstract class ZMRule
extends ZMObject

Base class for validation rules.

Author:
DerManoMann
Version:
$Id: ZMRule.php 2751 2009-12-17 22:45:44Z dermanomann $

Fields inherited from org.zenmagick.core.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.

void

setDefaultMsg(string msg)

Set the default error message.

void

setMsg(string msg)

Set a custom error message.

void

setName(string name)

Set the parameter name this rule is validating.

string

toJSString()

Create JS validation call.

abstract boolean

validate(ZMRequest request, array data)

Validate the given request data.

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

Constructor Detail

\mvc\validation\ZMRule.php at line 44

ZMRule

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

Create new validation rule.

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

Method Detail

\mvc\validation\ZMRule.php at line 114

getDefaultMsg

public string getDefaultMsg()

Get the default error message.

Returns:
The default error message.

\mvc\validation\ZMRule.php at line 153

getErrorMsg

public string getErrorMsg()

Return an appropriate error message.

Returns:
Localized error message.

\mvc\validation\ZMRule.php at line 96

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.

\mvc\validation\ZMRule.php at line 105

getMsg

public string getMsg()

Get the custom error message.

Returns:
The custom error message.

\mvc\validation\ZMRule.php at line 74

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.

\mvc\validation\ZMRule.php at line 132

setDefaultMsg

public void setDefaultMsg(string msg)

Set the default error message.

Parameters:
msg - The default error message.

\mvc\validation\ZMRule.php at line 123

setMsg

public void setMsg(string msg)

Set a custom error message.

Parameters:
msg - The custom error message.

\mvc\validation\ZMRule.php at line 83

setName

public void setName(string name)

Set the parameter name this rule is validating.

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

\mvc\validation\ZMRule.php at line 143

toJSString

public string toJSString()

Create JS validation call.

Returns an empty string.

Returns:
Formatted JavaScript .

\mvc\validation\ZMRule.php at line 66

validate

public abstract boolean validate(ZMRequest request, array data)

Validate the given request data.

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

ZenMagick 0.9.8