This commit is contained in:
43
api/app/Rules/Sigtap/Procedimento/Idade.php
Normal file
43
api/app/Rules/Sigtap/Procedimento/Idade.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules\Sigtap\Procedimento;
|
||||
|
||||
use App\Models\Sigtap\Procedimento;
|
||||
use App\Services\Sigtap\ProcedimentoValidationService;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
class Idade implements Rule
|
||||
{
|
||||
private Procedimento $procedimento;
|
||||
private int $idadeAnos;
|
||||
|
||||
public function __construct(Procedimento $procedimento, int $idadeAnos)
|
||||
{
|
||||
$this->procedimento = $procedimento;
|
||||
$this->idadeAnos = $idadeAnos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
$validation = new ProcedimentoValidationService($this->procedimento);
|
||||
|
||||
return $validation->isIdadeValid($this->idadeAnos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return ":attribute não permitido para a idade do paciente.";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user