ZenMagick 0.9.10


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

Class ZMRule

ZMObject
└─ZMRule

public abstract class ZMRule
extends ZMObject

Base class for validation rules.

Author:
DerManoMann

Fields inherited from org.zenmagick.core\ZMObject
properties_
Method Summary
void

__construct(string name, string defaultMsg, string msg)

Create new validation rule.

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
__construct, attachMethod, get, getAttachedMethods, getProperties, getPropertyNames, set, singleton

Method Detail

mvc\validation\ZMRule.php at line 43

__construct

public void __construct(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.

mvc\validation\ZMRule.php at line 113

getDefaultMsg

public string getDefaultMsg()

Get the default error message.

Returns:
The default error message.

mvc\validation\ZMRule.php at line 152

getErrorMsg

public string getErrorMsg()

Return an appropriate error message.

Returns:
Localized error message.

mvc\validation\ZMRule.php at line 95

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 104

getMsg

public string getMsg()

Get the custom error message.

Returns:
The custom error message.

mvc\validation\ZMRule.php at line 73

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 131

setDefaultMsg

public void setDefaultMsg(string msg)

Set the default error message.

Parameters:
msg - The default error message.

mvc\validation\ZMRule.php at line 122

setMsg

public void setMsg(string msg)

Set a custom error message.

Parameters:
msg - The custom error message.

mvc\validation\ZMRule.php at line 82

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 142

toJSString

public string toJSString()

Create JS validation call.

Returns an empty string.

Returns:
Formatted JavaScript .

mvc\validation\ZMRule.php at line 65

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.10