This commit is contained in:
41
api/app/Rules/Sigtap/Procedimento/ValidCompetencia.php
Normal file
41
api/app/Rules/Sigtap/Procedimento/ValidCompetencia.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules\Sigtap\Procedimento;
|
||||
|
||||
use App\Models\Sigtap\Procedimento;
|
||||
use App\Services\Sigtap\ProcedimentoValidationService;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
class ValidCompetencia implements Rule
|
||||
{
|
||||
private Procedimento $procedimento;
|
||||
|
||||
public function __construct(Procedimento $procedimento)
|
||||
{
|
||||
$this->procedimento = $procedimento;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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->isOnValidCompetencia();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return "Competência do :attribute inválida.";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user