Closed rvesse closed 8 years ago
Turns out we can't use Annotation
as the general type of a restriction but we can use Class<? extends Annotation>
so the definition will need to look something like the following:
@Option(name = "--example", arity = 2)
@PartialRestriction(index = 0, restriction = NotBlank.class)
@NotBlank
private List<String> examples;
And we'll need special logic in MetadataLoader
to load the list of @PartialRestriction
and modify generated restrictions as necessary
I have run into one bug which is that if you want to partially apply a postValidate()
based restriction this does not work because postValidate()
assumes the ability to see the full state. So we need to change that to finalValidate()
method and introduce a new postValidate()
method that sees the strongly typed value at the point at which it is introduced
More thoughts:
@Partials
to cope with the case where you want to define multiple @Partial
on a single fieldHelpHint
for PartialRestriction
in a sane mannerMetadataLoader
needs to obtain and act upon the @Partial
/@Partials
that are presentWill also need to document Migration because some of these changes are breaking
Finally it would be ideal if restrictions that make no sense as @Partial
error ASAP
Also it would be nice if the current means of enforcing restrictions is moved from the parsers into ParseState
so people can't write parsers that don't enforce the restrictions and we don't have to duplicate code so much
Everything but HelpHint
support is done
Added HelpHint
support so closing this now
Currently when a restriction is applied to an
@Option
or@Arguments
field it is enforced on every value that the option/argument takes regardless of the arity of said optionIt would be nice to be able to specify a restriction that only applies to a specific value e.g.
Note that the above approach may not work because I'm not sure we can specify that the
restriction
field takes any annotation (though if we can that would be great)The other approach would be to add an
appliesTo
field to all the existing restrictions where-1
indicates applies to all (the current default behaviour) and a positive integer indicates it applies to only the specific value