Guest User

Untitled

a guest
Jun 16th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. $casoValidator = Validator::attribute('nombre',Validator::allOf(Validator::stringType(),Validator::notOptional(),
  2. Validator::stringType()->length(3,100))) //nombre, validamos que sea cadena, que es obligatorio y que tiene de 3 a 100 caracteres
  3. ->attribute('idUsuario',Validator::allOf(Validator::intType()))
  4. ->attribute('numeroSertel',Validator::allOf(Validator::stringType(), Validator::stringType()->length(1,100)))
  5. ->attribute('dni',Validator::allOf(Validator::stringType(), Validator::stringType()->length(8,20))); //la capturaremos al hacer insert si hay problemas con las FK
  6.  
  7.  
  8. try {
  9. $asuntoValidator->assert($asunto);
  10.  
  11. } catch(NestedValidationException $exception) {
  12. $errors = $exception->findMessages([
  13. 'length' => '{{name}} no puede tener mas de 100 caracteres ni menos de uno',
  14. 'notOptional' => '{{name}} no es opcional',
  15. ....
Advertisement
Add Comment
Please, Sign In to add comment