Validated Field Items

Sometimes you want data to be entered in a certain format. For example in the Cambridge application the supply_point id seems to be entered in a format like “CAM-132776-SP”. To enforce data consistency and enhance data quality you would like to validate the correct string format during data entry.
These are the steps:

  • 1) Create a value_manager that will validate the input.
def_slotted_exemplar( :supply_point_id_value_manager,

_method supply_point_id_value_manager.validate(p_value)
    ## Validate that the string is in the format of
    ## CAM-909141-SP. First three characters, then 6 digits ended
    ## with SP.

    _if p_value _is _unset _then _return _endif 

    _local ok? << _self.is_valid?(p_value)

    _if _not ok?
        condition.raise(:supply_point_id_format_error, :string, p_value)
  • 2) Create a field_editor that uses the value_manager.
## Special field editor for entering the id of a supply_point.
def_slotted_exemplar( :supply_point_id_field_editor,

_private _method supply_point_id_field_editor.set_manager()
    ## Set the value manager to supply_point_id_value_manager.
    _self.manager << :field_item, _self.field_item )
  • 3) Publish the field_editor so it becomes available in the ACE editors.
                      _unset, { :alpha_field } )
  • 4) Assign the field_editor to the supply_point ID field in the ACE object property editor.
  • 5) Test it!
enjoy the quality boost!
I have attached the example sourcefiles for more detail information:
supply_point_id_field_editor.magik and supply_point_id_value_manager.magik
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License