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”)
This fixes a few documentation issues I noticed.
- Explain what Func is supposed to return.
- Remove change reference to ActualNamespace to mention StructNamespace
instead.
- Remove references to Validatable, which no longer exists.
- Fix godoc formatting.
- Delete extra text from ReportValidationErrors comment.
- Change ReportError interface definition so its arguments are named
consistently with what they do.