-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add regexp.Regexp support #7
Conversation
@kkyr just wanted to check in and ask if you'd consider including this. |
Hi @jparise, big thanks for the CR and apologies for the delay. I wasn't monitoring this account. Can you share the use case for having regex in an application's configuration? |
No worries! Here's an example that could be improved with built-in regex support: |
I'm OK adding this, however there are some things that need to be addressed in the CR first:
|
Thanks for the feedback! I believe I've addressed all of these items. |
It's useful to support validated regular expressions in configuration files. Previously, we could represent these fields as raw pattern strings and compile them in application code. By supporting Regexp as a first-class field type, we get a smaller application code and more immediate error reporting without complicating the API.
@@ -206,7 +207,7 @@ See example below to help understand: | |||
|
|||
err := fig.Load(&cfg) | |||
fmt.Print(err) | |||
// A: required, B: required, C: required, D: required, E: required, G: required, H.J: required, K: required, M: required | |||
// A: required validation failed, B: required validation failed, C: required validation failed, D: required validation failed, E: required validation failed, G: required validation failed, H.J: required validation failed, K: required validation failed, M: required validation failed, N: required validation failed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating to the latest error message
Merged. I'll include it in a new release that also bumps Go to 1.16. Thanks again for the PR! |
It looks like you've made those updates. Are you still planning on tagging a new release, too?
Sure thing! |
Yes, I’ll tag it this weekend |
It's useful to support validated regular expressions in configuration.
Previously, we could represent these fields as raw pattern strings and
compile them in application code. By supporting Regexp as a first-class
field type, we get a smaller application code and more immediate error
reporting without complicating the API.