Skip to content
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 startswith and endswith validators #459

Merged
merged 1 commit into from
Mar 31, 2019
Merged

Conversation

thcipriani
Copy link
Contributor

Make sure that you've checked the boxes below before you submit PR:

  • Tests exist or have been written that cover this particular change.

Change Details:

  • Add startswith and endswith validators
  • Provides general and useful functionality that seems to align with other validators
  • A very small wrapper around strings.HasPrefix and strings.HasSuffix
  • Enhances functionality vs contains validator
  • Was about to implement this in my own project, decided to make a pull request instead.

@go-playground/admins

`HasPrefix` and `HasSuffix` are both part of the `strings` package.
These seem like generally useful validations to include and cover some
subset of the use-cases of a general regex validator without having any
of the problems outlined by the validator docs.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 3945da1 on thcipriani:v9 into b199fa0 on go-playground:v9.

@deankarn
Copy link
Contributor

ey @thcipriani going to merge this, but could you also create another PR to add these validations to the documentation 🙏

@deankarn deankarn merged commit 9980009 into go-playground:v9 Mar 31, 2019
@thcipriani
Copy link
Contributor Author

ey @thcipriani going to merge this, but could you also create another PR to add these validations to the documentation 

@deankarn happy to! I added some info in doc.go, which seems to have made it to the documentation site -- should I be adding documentation elsewhere as well?

@deankarn
Copy link
Contributor

No that should be it thanks!

fairyhunter13 added a commit to fairyhunter13/validator that referenced this pull request Jul 12, 2020
Add `startswith` and `endswith` validators
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.

None yet

3 participants