The Validator component adds a robust/flexible validation framework. This component is also mostly optional, but can be super helpful as part of a param converter to ensure only valid data make it into the system. The Cookbook has an example of how this could be implemented. This component can also be used to define validation requirements for ART::Params::ParamInterfaces.
In addition to the general information for defining Custom Constraints, the validator component defines a specific type for defining service based constraint validators:
AVD::ServiceConstraintValidator. This type should be inherited from instead of
AVD::ConstraintValidator IF the validator for your custom constraint needs to be a service, E.x.
class Athena::Validator::Constraints::CustomConstraint < AVD::Constraint # ... @[ADI::Register] struct Validator < AVD::ServiceConstraintValidator def initialize(...); end # :inherit: def validate(value : _, constraint : AVD::Constraints::CustomConstraint) : Nil # ... end end end