In the earlier section, we have learned to create input fields using metadata, but an application would definitely need validation checks to be implemented to make it less prone to errors. Metadata provides an easy way to implement validation in the RhoSync application. Validation is expressed as a key added to an existing metadata definition. Below is a sample showing all of the validations that can be used.
Following options are available with Validation:
This is the simple code that we have to add validation:
:validation => { :regexp = "^.+$", :validators = [:required, :number, :currency, :email, :phone], :min_len = 0, :max_len = 100, :min_value = 10, :max_value = 1000 }
Now, to get the errors while validating, use the following code:
errors = validate(SourceName.metadata['validation'],@params)
validate
method is available with rhodes-translator
, which will form custom error messages depending...