Open timvisee opened 1 year ago
Why limit it to static? I can bet 2 seconds after this is released someone will want references
The point is to provide additional parameters to custom validators. Using arg
with external references is not an option in our case, partially because we use deeply nested structs.
I meant static as in hardcoded within the validate
attribute definition. Yes, that is something we're looking for in our case. That is to prevent boilerplate like this:
I'm looking for a way to add additional parameters to custom validator functions. For example:
This would be much better than having a separate function for each configuration such as
custom_range_1_128
andcustom_range_4_32
.This is different than the
arg = "(i32, i32)"
feature, becausearg
is to attach references to external data during validation withvalidate_args(...)
. Instead I'd like to specify static parameters inside the struct definitions itself.Is something like this currently possible? If not, can I submit a PR to implement this?
Note: I understand that in this example the built-in
range
validator would suffice. I'm just using range as easy to understand example rather than the more complex case I'm currently dealing with.