Validating an entity with a LogicalCondition

Hi,

Is it possible somehow to check if an entity instance matches a LogicalCondition before saving?
So if the same LogicalCondition would be used in a DataManager to run a query then the result would contain this entity instance after saving.

Thanks,
Peter

Hi,

Custom validation on an entity can be implemented in the ValidationEvent listener of the Edit screen, e.g.:

@Subscribe
public void onValidation(final ValidationEvent event) {
    if (!checkNameFormat()) {
        ValidationErrors errors = new ValidationErrors();
        errors.add(nameField, "Invalid name format");
        event.addErrors(errors);
    }
}

If I got you right, you need to test if an entity matches LogicalCondition from browse screen. In this case you need to pass LogicalCondition from browse screen to editor screen when opening it. Passing parameters to screen doc should help you with that.

The only problem here is to apply Condition to an entity. We don’t have API to do this, because conditions are applied to jpql queries. So, it’s all up to you.

Regards,
Gleb

Thank you, Gleb.
You got it right. I was interested in whether it was possible to apply a condition to an entity out of the box in Jmix.
We will find another solution.

Regards,
Peter