. */ declare(strict_types=1); namespace FireflyIII\Rules; use Illuminate\Contracts\Validation\ValidationRule; /** * Class IsBoolean */ class IsBoolean implements ValidationRule { /** * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function validate(string $attribute, mixed $value, \Closure $fail): void { if (is_bool($value)) { return; } if (0 === $value) { return; } if (1 === $value) { return; } if (in_array($value, ['0', '1', 'true', 'false', 'on', 'off', 'yes', 'no', 'y', 'n'], true)) { return; } $fail('validation.boolean')->translate(); } }