As far as I'm aware, there isn't a way for you to validate a field without explicitly defining validations. The reason that optional_?
and required_?
don't provide validation is that it isn't always clear what logic to use, especially for non String
fields. The required_?
value itself is used by Crudify to determine whether to mark the field as required in the produced UI, but it's up to you to provide the proper logic to determine that the requirement is satisfied.
Validating the field can be as easy as
override def validations = super.validations :: valMinLen(1, "Required!")
Or see the answer to your other question here for how to create a generic Required
trait.