SlimValidation icon indicating copy to clipboard operation
SlimValidation copied to clipboard

Validation of *oneOf*

Open codedge opened this issue 6 years ago • 0 comments

Hi,

is there any way to validate with oneOf from the Respect validation package?

v::oneOf(
  v::key('ip', v::notBlank()),
  v::key('q', v::notBlank()->alpha()
)

Of course this works but does not contain validation messages like the validator method.

I'd like to pass this to the validator to get the error messages in case there are some.

$validator = $this->validator->validate($request, [
            'ip' => v::optional(v::ip()),
            'country' => v::optional(v::countryCode())->in($this->country_codes),
            v::oneOf(
                v::key('ip', v::notBlank()),
                v::key('q', v::notBlank()->alpha())
            )
        ]);

Thanks

codedge avatar May 09 '19 12:05 codedge