Skip to content

Conversation

@Machine-Maker
Copy link
Contributor

@Machine-Maker Machine-Maker commented Jul 23, 2020

Added an @Regex annotation that can be applied to method parameters. The use cases for this, are small validation requirements, that don't warrant overriding a whole default context for, or registering a condition. Got this idea from Glare asking what the best way to only accept a 2 digit number was.

Copy link
Owner

@aikar aikar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really a fan of this because it can be done as a condition where you register a condition as regex for name then do

@Condition("regex:Foo[0-9]") instead.

This is simply another form of conditions but trying to lazily avoid having to register it yourself.

However, future plans would support the idea of registering a custom @Regex annotation that maps to @Condition("regex:xx") for you and id rather it just be done that way.

Because this is purely convenience over functionality, I'm going to say no to this as i feel this is best suited to user land so that the condition is checked at same place as conditions.

Now, what we can do is simply default register a condition for regex, so everyone can use @Condition("regex:XXX") on their parameters out of the box.

So please update the PR to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants