# new mendix/lib/ObjectValidation(guid, fields)
Parameters:
Name | Type | Description |
---|---|---|
guid |
string
|
|
fields |
Object.<string, string>
|
validation message for each attribute |
Methods
# addAttribute(attr, message) → {boolean}
Add validation message message
for attribute attr
if there isn't
one.
Parameters:
Name | Type | Description |
---|---|---|
attr |
string
|
attribute name of the validation field |
message |
string
|
reason of the failed validation |
returns true
if there is no message for attr
, false
otherwise
boolean
# clone() → {ObjectValidation}
Return a clone of this object.
ObjectValidation
Example
val clonedVal = val.clone();
clonedVal.getErrorReason("Username") === val.getErrorReason("Username"); // true
# getAttributes() → {Array.<{name: string, reason: string}>}
Returns attributes which did not pass validation.
array of validation failures
Array.<{name: string, reason: string}>
Example
var fields = val.getFields();
// fields will be [ { name: "username", reason: "Username already in use" },
// { name: "zipcode", reason: "Invalid zip code" } ]
# getErrorReason(attr) → {string}
Return the validation message for attribute attr
.
Parameters:
Name | Type | Description |
---|---|---|
attr |
string
|
attribute to return the validation message for |
validation message for the given attribute or null
if attr
is valid
string
# getFields()
# getGuid() → {string}
Returns the GUID
of the validated MxObject
.
GUID
of the validated object
string
# removeAttribute(attr) → {boolean}
Remove validation message for attribute attr
.
Parameters:
Name | Type | Description |
---|---|---|
attr |
string
|
attribute name of the validation field to be removed |
returns false
if there is no message for attr
, true
otherwise
boolean