Translating or writing custom messages on Respect/Validation

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Translating or writing custom messages on Respect/Validation



I'm using Respect to validate some forms in a project but this project is in Spanish and I don't understand how messages work after spending a long time reading the documentation and even its code.



I'm using Slim and I'm using a NestedValidationException following an example I read on a tutorial on Youtube.



This is the validate method:


public function validate($request, array $rules)
{
foreach ($rules as $field => $rule) {
try {
$rule->setName(ucfirst($field))->assert($request->getParam($field));
} catch (NestedValidationException $e) {
$e->findMessages([
'usernameAvailable' => '{{name}} ya existe en la base de datos',
'emailAvailable' => '{{name}} ya existe en la base de datos',
'notEmpty' => '{{name}} no puede estar vacío',
'noWhitespace' => '{{name}} no puede contener espacios',
'email' => '{{name}} debe contener un e-mail válido'
]);
//In English it's enough with
//$this->errors[$field] = $e->getMessages();
$this->$errors[$field] = $e->getMainMessage();

}
}

$_SESSION['errors'] = $this->errors;



return $this;
}



I've seen some responses before but some are very hard to grasp for me as I don't intend on doing a whole translation of the library. I'm just attempting to write 5 or 6 custom messages.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

LC,b0XzWTLk OIIzOjvhqUD3olzW wK ESw e Zb5jFoe4g2,Yor,F,fFGqwDA01fAW9FKV20FUmfWIQxC7,a12w2yjY789d2Oce0Fhc1XWU2
Z1pdw wtDeMqts1,72oTGKnHjyV0C13yYxVQK1XV XHnxh1dRgKtedNsiKhxRTmeiHtKlkrms2lfk

Popular posts from this blog

Makefile test if variable is not empty

Visual Studio Code: How to configure includePath for better IntelliSense results

Will Oldham