Validation library and rules to generate pix
This commit is contained in:
parent
b2d14abbce
commit
337f1945ff
1 changed files with 24 additions and 1 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
use Somnambulist\Components\Validation\Factory;
|
||||
|
||||
function pixCobrancaImediataRules(array $data)
|
||||
function pixCobrancaImediataComValorRules(array $data)
|
||||
{
|
||||
$rules = [
|
||||
'expiracao' => 'integer',
|
||||
|
@ -23,3 +23,26 @@ function pixCobrancaImediataRules(array $data)
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function pixCobrancaImediataSemValorRules(array $data)
|
||||
{
|
||||
$rules = [
|
||||
'expiracao' => 'integer',
|
||||
'devedor' => 'array',
|
||||
'devedor.documento' => 'string|min:11|max:18',
|
||||
'devedor.nome' => 'required_with:devedor.documento|string|max:100',
|
||||
'valor' => 'sometimes|integer',
|
||||
'chave' => 'required|string',
|
||||
'txid' => 'required|string|max:100',
|
||||
'solicitacaoPagador' => 'string|max:140'
|
||||
];
|
||||
|
||||
$validation = (new Factory)->validate($data, $rules);
|
||||
|
||||
if ($validation->fails()) {
|
||||
throw new Exception(json_encode($validation->errors()->firstOfAll()), 500);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue