25 lines
506 B
PHP
25 lines
506 B
PHP
<?php
|
|
|
|
namespace App\Rules\AtencaoBasica\Exportacao;
|
|
|
|
use App\Enums\Imunizacao\Estrategia;
|
|
use Illuminate\Contracts\Validation\Rule;
|
|
|
|
class EstrategiaIsValid implements Rule
|
|
{
|
|
public function passes($attribute, $value)
|
|
{
|
|
return self::isValid($value);
|
|
}
|
|
|
|
public static function isValid($value)
|
|
{
|
|
return $value && in_array($value, array_column(Estrategia::getConstants(), null));
|
|
}
|
|
|
|
public function message()
|
|
{
|
|
return 'Estratégia inválida.';
|
|
}
|
|
}
|