Namespace: Validation

Validation

Validation is provided as a constructor function that can initialise an Angular service or a Node module. It provides all functionality necessary to validate an XML submission against a form model, including: Initialisation of a form data object from a given form view model. Importing data from XML into a given form data object. Validation of any view model item given a reference to its node within the form data object.

Methods


Validation.defaultData(item)

Gets the default data context for the provided item.
Parameters:
Name Type Description
item
Returns:
Type
Object

Validation.hasValue(item, data)

Determines if the provided item has a value within the provided data context.
Parameters:
Name Type Description
item
data
Returns:
Returns `true` if the provided item has a value within the provided data context.
Type
boolean

Validation.registerHasValueHandler(type, hasValueFn)

Register a function that is used to check if a component has a value
Parameters:
Name Type Description
type string Name of the type to check against for the has value check
hasValueFn function Function that checks an item to validate that it has a value.
Since:
  • Maestro 22.04.0

Validation.registerValidationHandler(type, validationFn)

Register a function that is used to check if a component passes the mandatory requirement of being completed
Parameters:
Name Type Description
type string Name of the type to check against for the mandatory check
validationFn function Function that checks an item to validate that it has fulfilled the validation requirement for the field.
Since:
  • Maestro 22.04.0

Validation.validate(item, data)

Validates the provided item and its children provided its data context.
Parameters:
Name Type Description
item
data The data node of which this item's data is a property with key = item.id
Returns:
of {valid: boolean, errors: array}
Type
Object