validation rules
This commit is contained in:
parent
a91b6e8650
commit
b2d14abbce
2 changed files with 21 additions and 4 deletions
|
@ -17,6 +17,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"phpseclib/phpseclib": "~3.0"
|
"phpseclib/phpseclib": "~3.0",
|
||||||
|
"somnambulist/validation": "^1.12"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,25 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function pixCobrancaImediataRules(array $data){
|
use Somnambulist\Components\Validation\Factory;
|
||||||
|
|
||||||
|
function pixCobrancaImediataRules(array $data)
|
||||||
|
{
|
||||||
$rules = [
|
$rules = [
|
||||||
'valor' => 'required|integer',
|
|
||||||
'expiracao' => 'integer',
|
'expiracao' => 'integer',
|
||||||
'devedor' => 'sometimes|string'
|
'devedor' => 'array',
|
||||||
|
'devedor.documento' => 'string|min:11|max:18',
|
||||||
|
'devedor.nome' => 'required_with:devedor.documento|string|max:100',
|
||||||
|
'valor' => 'required|integer|min:1',
|
||||||
|
'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