ardent icon indicating copy to clipboard operation
ardent copied to clipboard

>1 custom validations results in bizarre errors

Open vanimurarka opened this issue 11 years ago • 0 comments

If I have more than one custom validation, it screws up my test results big time. The errors reported are bizarre.

Till my model had 1 custom validation rule, things were fine.

Eg. scenario: Validator::extend('book_exists', function($field, $value, $params) { try { $book = FlatBook::findOrFail($value); } catch (Exception $e) { return false; } return true;

}); Validator::extend('user_active', 'UserAccess@validateUserActive');

In the model: public static $rules = array( 'UserID' => 'required|user_active', 'BookID' => 'required|book_exists' );

I get errors like:

  • Bad Method Call validateUserActive does not exist (when it does)
  • Creating default object from empty value
  • Table 'user_active' does not exist

Indeed this table does not exist - it is nowhere in my schema. Only place where this term exists is as a place in the validation rule.

vanimurarka avatar Sep 13 '14 07:09 vanimurarka