2
I need to do a composite validation on the Activejdbc ORM and I’m not finding anything in the documentation. Something like, extends from the Validatoradapter class, but I’m not finding material to use as an example.
Basically:
public class Competencia extends Model{
static{
validateWith(new UniquenessValidator("mes", "ano")).message("O número de documento já existe");
}
}
I managed to make (picked up from a friend) the Uniqueness with a field, but I’m having difficulties to make for two fields. How can I get around this difficulty, will anyone have some similar example?
I guess you’ll have to write your own
Validator
based on theUniquenessValidator
. For example, getting a varargString... attributes
and modifying the methodvalidate
to consider all attributes received in the query. If you do this check that the table is properly indexed or the solution will suffer due to performance of consultation.– Anthony Accioly