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
Efficient Regex Validation Integration #1115
base: master
Are you sure you want to change the base?
Conversation
I will need to think about this, again, as in the documentation I explicitly state why I do not already have a
|
Thank you for your response. I have inspired this validation from Laravel regex validation and as developers we occasionally need to validate based on regex pattern, for example: validating custom date format or the country code. Furthermore, regarding translation message I have added a general message for all supported languages which is "invalid format" and this message returns for any invalid case. We can pass a custom message from the definition of regex as a tag field. However, I would like to contribute with this library and help to develop new features. |
@yousifnimah yep I understand and makes sense. You can also do this today by registering a custom validation with tag that uses the Regex internals which may be more maintainable. How do you propose to deal with the conflicting characters? |
I've added a handler for comma representation and it would be like this:
The usage in the struct tag:
It represents this pattern:
And it works fine. |
Enhances
This pull request introduces an optimized version of the code that enables the validation of field values using custom regex patterns specified through tags. The improvements made to the code enhance efficiency, readability, and flexibility. The custom regex patterns can be easily associated with fields using tags, allowing for seamless validation based on specific requirements.
Here's a summary of the changes made:
regexp.Compile
Example of usage: