Validation
This is the official documentation of the agent_ruby Ruby agent.

Columns of type
VARCHAR(15)will automatically carry aless than 15 charsvalidator.Non-nullable columns will automatically carry a
Presentvalidator.
However, you may want to enforce stricter restrictions than the ones which are implemented in your data source.
Adding validation rules
The list of operators (Present, LongerThan, ...) which can be used when adding validators is the same as the filter operators.
include ForestAdminDatasourceToolkit::Components::Query::ConditionTree
@create_agent.customize_collection('customer') do |collection|
collection.add_field_validation('firstName', Operators::PRESENT)
.add_field_validation('firstName', Operators::LONGER_THAN, 2)
.add_field_validation('firstName', Operators::SHORTER_THAN, 13)
.add_field_validation('firstName', Operators::MATCH, /^[a-z]+$/)
endLast updated
Was this helpful?