Fixes Or Enhances https://github.com/go-playground/validator/issues/518.
Make sure that you've checked the boxes below before you submit PR:
[x] Tests exist or have been written that cover this particular change.
Change Details:
The datauri validation was not allowing certain valid strings; this
commit updates the regex to meet RFC 2397. I drew heavily on this gist
https://gist.github.com/khanzadimahdi/bab8a3416bdb764b9eda5b38b35735b8,
but had to make a few updates to remove some negative lookaheads (which
Go doesn't allow afaik), and to account for the way the `isDataURI`
function works - it validates the base64 separately from the other parts
of the uri.
@go-playground/admins
Fixes Or Enhances https://github.com/go-playground/validator/issues/525.
**Make sure that you've checked the boxes below before you submit PR:**
- [x] Tests exist or have been written that cover this particular change.
Change Details:
* Adds the ability to match on space separated strings when using the
`oneof` validation. Space separted strings must be surrounded by single
quotes to be validated as one string. For example:
```
oneof='Awaiting Verification' 'Verified' 'Failed Verification'
```
passes validation for a field that is exactly `Failed Verification`
(though just `Failed` would...fail).
@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.
It was originally intended for these to only be used on strings, however
it makes sense to also use them if your dealing with type interface{}
so now ints and floats return true for this validation also as they are
both numeric and numbers.
closes#356
Validates that a string or number value equals one of a set of allowed values. Examples:
validator.Var(“red”, “oneof=red green”)
validator.Var(6, “oneof=6 7 8”)