Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $casoValidator = Validator::attribute('nombre',Validator::allOf(Validator::stringType(),Validator::notOptional(),
- Validator::stringType()->length(3,100))) //nombre, validamos que sea cadena, que es obligatorio y que tiene de 3 a 100 caracteres
- ->attribute('idUsuario',Validator::allOf(Validator::intType()))
- ->attribute('numeroSertel',Validator::allOf(Validator::stringType(), Validator::stringType()->length(1,100)))
- ->attribute('dni',Validator::allOf(Validator::stringType(), Validator::stringType()->length(8,20))); //la capturaremos al hacer insert si hay problemas con las FK
- try {
- $asuntoValidator->assert($asunto);
- } catch(NestedValidationException $exception) {
- $errors = $exception->findMessages([
- 'length' => '{{name}} no puede tener mas de 100 caracteres ni menos de uno',
- 'notOptional' => '{{name}} no es opcional',
- ....
Advertisement
Add Comment
Please, Sign In to add comment