Skip to content

Instantly share code, notes, and snippets.

@raank
Created November 8, 2016 19:44
Show Gist options
  • Save raank/9f1446f20ef6f30be3a585f50f5dbc8f to your computer and use it in GitHub Desktop.
Save raank/9f1446f20ef6f30be3a585f50f5dbc8f to your computer and use it in GitHub Desktop.
<?php namespace SyncMedic\Validators;
use \Prettus\Validator\Contracts\ValidatorInterface;
use \Prettus\Validator\LaravelValidator;
class LoginValidator extends LaravelValidator
{
//RULES
protected $rules = [
ValidatorInterface::RULE_CREATE => [
'email' => 'required|email',
'password' => 'required|AlphaNum|Between:4,8',
],
ValidatorInterface::RULE_UPDATE => [
'email' => 'required|email',
'password' => 'required|AlphaNum|Between:4,8',
]
];
//CUSTOM MESSAGE
protected $messages = [
// exemplo: 'email.required' => 'O campo e-mail é obrigatório'
'required' => 'O campo :attribute é obrigatório.',
'email' => 'O campo :attribute inválido',
'AlphaNum' => 'Sua :attribute deve conter letras e números.',
'Between' => 'Sua :attribute deve ter de 4 à 8 caracteres'
];
//ATTRIBUTES
protected $attributes = [
'email' => 'E-mail',
'password' => 'Senha'
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment