Class

mendix/lib/ObjectValidation

mendix/lib/ObjectValidation(kwArgs)

Contains messages of a failed MxObject validation. The terms fields and attributes are used interchangeably, so some methods have aliases reflecting this.

Constructor

# new mendix/lib/ObjectValidation(kwArgs)

Parameters:
Name Type Description
kwArgs Object

validation message

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

# 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