-
Notifications
You must be signed in to change notification settings - Fork 60
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
Allow regex specified custom string validation #56
Comments
OliveTin/internal/executor/executor.go Lines 18 to 26 in 2d71577
looks like these are the regex patterns for existing validations OliveTin/internal/config/config.go Lines 16 to 23 in 2d71577
The config def for arguments for an action. OliveTin/internal/executor/executor.go Lines 279 to 302 in 2d71577
The implementation of actual regex type checking. The most logical thing would be to refactor TypeSafetyCheck into a general regex check, which is called by the builtin typed versions, as well as by the regex type'd version. |
Hey @matthewstrasiotto , thanks for taking a look at this one. I agree that having the option to add custom regex will help a lot of users where they want to be more specific about input type. Implementation guidance;
Functional requirements;
Thanks again for taking a look at this, and I really appreciate your time in considering to make a contribution to OliveTin! I've got an open mind if you think I may have missed something in the guidance/requirements above, or you'd like to discuss a different approach. |
Hey @matthewstrasiotto , how are you coming with this? Is there any additional help I can offer? |
@strazto ping :-) ^^ |
I decided just to implement this myself in the end. I changed my mind, and just used a |
From #42 (comment)
Is your feature request related to a problem? Please describe.
We want to avoid allowing the
very_dangerous_raw_string
input type, and impose restrictions on allowed characters and patterns, however the input constraints change from application to application, for example, URLs have different requirements to other strings.Though having some built-in defaults to cover common use-cases makes a lot of sense (int, uint, ascii, ascii_sentence, url, etc) there may be more complex patterns that require custom logic, eg,
dttm: YY-MM-DD hh:mm
, etc.A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
Allowing users to specify regex validation patterns in their configuration, (and maybe also a message format hint) might be a good way to accomodate this, for example:
#42 (comment)
Describe alternatives you've considered
There might be other mechanisms to configure safe, customizable string escaping + validation, but I do think this is probably the most flexible + intuitive way to allow this.
Additional context
I also think there should be an optional config option for input format hints, which are displayed on the front-end, both for custom types and for the built-in types, eg:
Taken from regextester
The equivalent for a builtin, say,
int
:This might render as:
https://www.w3.org/WAI/tutorials/forms/instructions/
https://medium.com/nextux/form-design-best-practices-9525c321d759
Or just put the hint in the placeholder
The text was updated successfully, but these errors were encountered: