public function testValidationFailed() { $rule = new ValidateOldPassword(); $user = new User(); $user->password = '******'; $this->assertFalse($rule->validate('', '123', [$user->password])); }
/** * */ public function boot() { //Add validator for old password $this->app['validator']->extend('old_password', function ($attribute, $value, $parameters) { //Generate the rules $validator = new ValidateOldPassword(); //Validate the rulesĀ return $validator->validate($attribute, $value, $parameters); }); //Add validator for user uniqueness $this->app['validator']->extend('user_is_unique', function ($attribute, $value, $parameters) { //Generate the rules $validator = app(ValidateUserIsUnique::class); //Validate the rulesĀ return $validator->validate($attribute, $value, $parameters); }); }