Class: mendix/lib/ObjectValidation

mendix/lib/ObjectValidation

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:

returns true if there is no message for attr, false otherwise

Type
boolean

addField()

See:

clone() → {ObjectValidation}

Return a clone of this object.

Returns:
Type
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.

Returns:

array of validation failures

Type
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

Returns:

validation message for the given attribute or null if attr is valid

Type
string

getFields()

See:

getGuid() → {string}

Returns the GUID of the validated MxObject.

Returns:

GUID of the validated object

Type
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:

returns false if there is no message for attr, true otherwise

Type
boolean

removeField()

See: