Validation provides the ability to control input from a user onto the database or to restrict the function of a specific format of data.
For example, validation can be used to restrict
GnEditText to accept only numbers where the entry field is used for phone numbers or to limit the length of a validation field etc…
To emphasise validation, the designer is encouraged to add in
TextView text that describes input field.
Validators perform validation on widgets.
To execute a validation on a widget, a validator must be attached to it (validator is an XML attribute).
All validators have two obligatory(*) attributes,
Widgets can also have multiple validators attached, for example:
<EditText android:id="@+id/telNumber" android:layout_width="150dp" android:layout_height="wrap_content" gn:act_validate="[name:RequiredValidator],[message=Telephone number field is required]" gn:act_validate="[name:TextValidator],[message=Text validation failed],[inputType=NUMBER],[NUMBERErrMsg=Has to be number]" gn:data_field="number" gn:data_requet="assets" />
- Requires attaching a validator to a widget
- Validates fields after entry.
- Requires widgets that will be validated to contain immediate validators as well as widget that will complete a whole screen validation to contain screen validation attribute.