@Size Constraint not working

Hi,

I am introducing the BeanValidation constraints in my entities, and am finding that the constraint @Size associated to a List is not being detected. Have even included the group UiCrossFieldChecks.class just in case. But now working either.

@Size(message = "Al menos registrar una seccion", min = 1, groups = UiCrossFieldChecks.class)
    @OnDeleteInverse(DeletePolicy.UNLINK)
    @OnDelete(DeletePolicy.CASCADE)
    @OneToMany(mappedBy = "modeloContrato", cascade = CascadeType.ALL)
    protected List<Seccion> secciones = new ArrayList<Seccion>();

Any help is greatly appreciated.

Regards,

Carlos.

Hi,

Entity attribute constraints defined by annotations like @Size, @NotNull, etc. are added to a UI component that represents the corresponding entity attribute in an editor screen. Since the Table component has no validators, @Size is ignored. For instance, if you represent a collection attribute with a field component like TokenList, then validation will be successfully triggered:

52

The UiCrossFieldChecks group is used when validating class-level constraints on entity editor commit, e.g.:

@CheckTaskFeasibility(groups = {Default.class, UiCrossFieldChecks.class}) // custom validation annotation
@Table(name = "DEMO_TASK")
@Entity(name = "demo_Task")
public class Task extends StandardEntity {
    //...
}

In order to resolve your issue, I would recommend either create class-level constraint (see doc) or implement the validateAdditionalRules method in the entity editor.

Regards,
Gleb

Thanks. sorry for not coming back earlier. Will approach validations soon, so I will soon have the chance to test your proposals.

Regards,

Carlos.