rule helper

Previous Next

The rule helper can be used to add domain attributes to an HTML element. Domain attributes can be used by domain validators.

Syntax

{{ rule "*" }}

The "*" parameter is required.

 

Example

<input {{rule "*"}}/>

can be converted to:

<input udb-mandatory="true" udb-ioformat="DD-MM-YYYY"/>

 

Explanation

The added attributes are used for field validation. The construct iterates over all attributes of a JSON control definition and adds rule attributes depending on whether a rule has been defined for that attribute in the factory definition:

$.udb.ui.registerControl("Control", null, {

 

 templateOptions: {

         data: {

                 rules: {

                         mandatory: function(value, options) {

                                 return (value ? {rule: "udb-mandatory", value: true} : undefined);

                         }

                 }

         }

 },

 

};

At this time, rule attributes are supported for mandatory, io-format, domain values and numeric values.