Skip to content

Commit a71ad15

Browse files
committed
fix: revert passes() function
1 parent c7c81ca commit a71ad15

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/RifValidationServiceProvider.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ public function boot()
1717
$this->loadTranslationsFrom(__DIR__.'/../lang/', 'validateRif');
1818

1919
// Register custom validation rule
20-
$this->app['validator']->extend('rif', function ($attribute, $value, $parameters, $validator) {
21-
return (new Rif())->validate($attribute, $value, function ($message) {
22-
return $message;
23-
});
24-
});
20+
$this->app['validator']->extend('rif', Rif::class . '@passes');
2521
}
2622
}

src/Rules/Rif.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,18 @@ public function validate(string $attribute, mixed $value, Closure $fail): void
3838

3939
$fail(Str::replace(':attribute', $this->attribute, __('validateRif::messages.rif')));
4040
}
41+
42+
/**
43+
* Determine if the RIF validation rule passes.
44+
*
45+
* @param string $attribute
46+
* @param mixed $value
47+
* @return bool
48+
*/
49+
public function passes($attribute, $value): bool
50+
{
51+
$this->attribute = $attribute;
52+
53+
return $this->validator->isValid($value);
54+
}
4155
}

0 commit comments

Comments
 (0)