I suspect I’m approaching this task wrongly.
In my web application, I would like to gather the URL params into a Class that can validate the incoming params the way dry-validation does, with the utility of Dry-Struct. The class would be passed to a command handler the would invoke the validation method before processing the contents of the command.
I’ve read the doc and understand how to define a validation schema, and how to define a typed struct. However, for what I’m trying to achieve I’d like to call the schema.call() inside the struct class. Creating a schema and a typed struct for each logical URL entry seems too heavy or overdone.
The result of these efforts should produce a single value object-like class whose contents can be trusted according to the validation rules that filtered the input. Once I become comfortable with the approach I expect to create a couple hundred of these, one for each URL entry.
The URL input will always be a hash with string keys, could make them symbols in a preprocessor, and will likely be nested; with an average of eleven params. I’m interested in existence and value types and ranges.
Should I just use Dry-Struct and depend on it throwing an exception during create?
Or somehow incorporate Dry-Validation and call the schema method to validate in a more controlled fashion.
Or only use Dry-validation and use the validation method as needed, and use the result as the command object to pass onto the handler. note: yes I want dot-notation on the result.
Or wrap Dry-Validation into a class of my own making with the aid of Dry-Struct. This seems like a workable approach.
Help me take the first step.