This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules\AtencaoBasica\Exportacao;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
class DataNascimentoIsValid implements Rule
|
||||
{
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
return self::isValid($value);
|
||||
}
|
||||
|
||||
public static function isValid($value)
|
||||
{
|
||||
|
||||
$dataAtendimento = Carbon::parse($value['data_atendimento']);
|
||||
$dataNascimentoPaciente = Carbon::parse($value['data_nascimento']);
|
||||
|
||||
$limiteInferior = $dataAtendimento->copy()->subYears(130);
|
||||
$limiteSuperior = $dataAtendimento->copy();
|
||||
|
||||
return $dataNascimentoPaciente->isBetween($limiteInferior, $limiteSuperior);
|
||||
}
|
||||
|
||||
public function message()
|
||||
{
|
||||
return 'Data de nascimento inválida';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user