making / yavi

Yet Another Validation for Java (A lambda based type safe validation framework)
https://yavi.ik.am
Apache License 2.0
743 stars 61 forks source link

Added support for inheritance hierarchies validation #369

Open ArielBerkovich opened 5 months ago

ArielBerkovich commented 5 months ago

added constraintOnClass api to resolve issue: https://github.com/making/yavi/issues/278

this provides convenient API to create a parent class validator that can also validate different inherited classes extending it.

example:

given a class called Child that extends Parent, one could utilize constraintOnClass in the following way:

    ValidatorBuilder.<Parent>of()
                // constraints for parent
                .constraint(...)
                .constraintOnClass(Child.class), b -> b
                            // constraints for child
                            .constraint(...)
                            .constraint(...)
                            .constraint(...)
                    )
                )