laravelvalidationlaravel-formrequest

Numeric|max Throws Bad Method Call Exception


I'm recieving the following error from the from request class in Laravel.

BadMethodCallException: Method Illuminate\Validation\Validator::validateNumeric|max does not exist.
in /var/www/html/vendor/laravel/framework/src/Illuminate/Validation/Validator.php:1532

This is my validation rule:

['required', 'integer', 'numeric|max:90', new UniqueWhenNew]

The value I passed is 70.

Apperantly, this is a strange situation because I didn't find anything similar on Google.

I hope someone knows what is the issue. Thanks in advance.


Solution

  • You can either use all rules in string or array.

    $rules = ['required', 'integer', 'numeric', 'max:90', new UniqueWhenNew]