Skip to content

Commit

Permalink
feat(core): implement translatable validation attribute errors
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideIadeluca committed Oct 12, 2024
1 parent bfde624 commit d890c23
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
10 changes: 10 additions & 0 deletions framework/core/src/Api/ForgotPasswordValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,14 @@ class ForgotPasswordValidator extends AbstractValidator
protected $rules = [
'email' => ['required', 'email']
];

/**
* {@inheritdoc}
*/
protected function attributes()
{
return [
'email' => $this->translator->trans('validation.attributes.email')
];
}
}
10 changes: 10 additions & 0 deletions framework/core/src/Discussion/DiscussionValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@ class DiscussionValidator extends AbstractValidator
'max:80'
]
];

/**
* {@inheritdoc}
*/
protected function attributes()
{
return [
'title' => $this->translator->trans('validation.attributes.title')
];
}
}
11 changes: 11 additions & 0 deletions framework/core/src/Group/GroupValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,15 @@ class GroupValidator extends AbstractValidator
'name_singular' => ['required'],
'name_plural' => ['required']
];

/**
* {@inheritdoc}
*/
protected function attributes()
{
return [
'name_singular' => $this->translator->trans('validation.attributes.name_singular'),
'name_plural' => $this->translator->trans('validation.attributes.name_plural'),
];
}
}
10 changes: 10 additions & 0 deletions framework/core/src/Post/PostValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,14 @@ class PostValidator extends AbstractValidator
'max:65535'
]
];

/**
* {@inheritdoc}
*/
protected function attributes()
{
return [
'content' => $this->translator->trans('validation.attributes.content')
];
}
}
12 changes: 12 additions & 0 deletions framework/core/src/User/UserValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,16 @@ protected function getMessages()
'username.regex' => $this->translator->trans('core.api.invalid_username_message')
];
}

/**
* {@inheritdoc}
*/
protected function attributes()
{
return [
'username' => $this->translator->trans('validation.attributes.username'),
'email' => $this->translator->trans('validation.attributes.email'),
'password' => $this->translator->trans('validation.attributes.password')
];
}
}

0 comments on commit d890c23

Please sign in to comment.