Skip to content

Commit

Permalink
Merge pull request FriendsOfSymfony#230 from zocimek/validation-messages
Browse files Browse the repository at this point in the history
Validation messages
  • Loading branch information
zocimek committed Jul 11, 2014
2 parents cab9c3d + 9e069c1 commit fdc9e1b
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 18 deletions.
28 changes: 14 additions & 14 deletions Resources/config/validation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<constraint name="FOS\MessageBundle\Validator\Authorization" />
<constraint name="FOS\MessageBundle\Validator\SelfRecipient" />
<constraint name="NotBlank">
<option name="message">No recipient specified</option>
<option name="message">fos_message.recipients.blank</option>
</constraint>
<constraint name="Type">
<option name="type">FOS\MessageBundle\Model\ParticipantInterface</option>
Expand All @@ -19,23 +19,23 @@
</property>
<property name="subject">
<constraint name="NotBlank">
<option name="message">Please enter a subject</option>
<option name="message">fos_message.subject.blank</option>
</constraint>
<constraint name="Length">
<option name="min">2</option>
<option name="max">255</option>
<option name="minMessage">The subject is too short|The subject is too short</option>
<option name="maxMessage">The subject is too long|The subject is too long</option>
<option name="minMessage">fos_message.subject.short</option>
<option name="maxMessage">fos_message.subject.long</option>
</constraint>
</property>

<property name="body">
<constraint name="NotBlank">
<option name="message">Please enter a body</option>
<option name="message">fos_message.body.blank</option>
</constraint>
<constraint name="Length">
<option name="min">2</option>
<option name="minMessage">The body is too short</option>
<option name="minMessage">fos_message.body.short</option>
</constraint>
</property>
</class>
Expand All @@ -48,7 +48,7 @@
<constraint name="FOS\MessageBundle\Validator\Authorization" />
<constraint name="FOS\MessageBundle\Validator\SelfRecipient" />
<constraint name="NotBlank">
<option name="message">No user with that username</option>
<option name="message">fos_message.recipient.blank</option>
</constraint>
<constraint name="Type">
<option name="type">FOS\MessageBundle\Model\ParticipantInterface</option>
Expand All @@ -57,23 +57,23 @@

<property name="subject">
<constraint name="NotBlank">
<option name="message">Please enter a subject</option>
<option name="message">fos_message.subject.blank</option>
</constraint>
<constraint name="Length">
<option name="min">2</option>
<option name="max">255</option>
<option name="minMessage">The subject is too short|The subject is too short</option>
<option name="maxMessage">The subject is too long|The subject is too long</option>
<option name="minMessage">fos_message.subject.short</option>
<option name="maxMessage">fos_message.subject.long</option>
</constraint>
</property>

<property name="body">
<constraint name="NotBlank">
<option name="message">Please enter a body</option>
<option name="message">fos_message.body.blank</option>
</constraint>
<constraint name="Length">
<option name="min">2</option>
<option name="minMessage">The body is too short|The body is too short</option>
<option name="minMessage">fos_message.body.short</option>
</constraint>
</property>

Expand All @@ -85,11 +85,11 @@

<property name="body">
<constraint name="NotBlank">
<option name="message">Please enter a body</option>
<option name="message">fos_message.body.blank</option>
</constraint>
<constraint name="Length">
<option name="min">2</option>
<option name="minMessage">The body is too short|The body is too short</option>
<option name="minMessage">fos_message.body.short</option>
</constraint>
</property>

Expand Down
17 changes: 17 additions & 0 deletions Resources/translations/validators.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
fos_message:
recipient:
blank: No recipient specified
recipients:
blank: No recipients specified
subject:
blank: Please enter a subject
too_short: The subject is too short|The subject is too short
too_long: The subject is too long|The subject is too long
body:
blank: Please enter a body
too_short: The body is too short
spam: Sorry, your message looks like spam
not_authorized: You are not allowed to send this message
reply_not_authorized: You are not allowed to reply to this message
self_recipient: You cannot send a message to yourself

17 changes: 17 additions & 0 deletions Resources/translations/validators.pl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
fos_message:
recipient:
blank: Nie zdefiniowano odbiorcy
recipients:
blank: Nie zdefiniowano żadnych odbiorców
subject:
blank: Wprowadź temat
short: Temat jest za krótki|Temat jest za krótki
long: Temat jest za długi|Temat jest za długi
body:
blank: Wprowadź treść
short: Treść jest za krótka
spam: Przykro mi, Twoja wiadomość wygląda jak spam
not_authorized: Nie masz uprawnień, aby wysłać tą wiadomość
reply_not_authorized: Nie masz uprawnień, aby odpowiadać na tą wiadomość
self_recipient: Nie możesz wysyłać wiadomości do siebie

2 changes: 1 addition & 1 deletion Validator/Authorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Authorization extends Constraint
{
public $message = 'You are not allowed to send this message';
public $message = 'fos_message.not_authorized';

public function validatedBy()
{
Expand Down
2 changes: 1 addition & 1 deletion Validator/ReplyAuthorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class ReplyAuthorization extends Constraint
{
public $message = 'You are not allowed to reply to this message';
public $message = 'fos_message.reply_not_authorized';

public function validatedBy()
{
Expand Down
2 changes: 1 addition & 1 deletion Validator/SelfRecipient.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class SelfRecipient extends Constraint
{
public $message = 'You cannot send a message to yourself';
public $message = 'fos_message.self_recipient';

public function validatedBy()
{
Expand Down
2 changes: 1 addition & 1 deletion Validator/Spam.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Spam extends Constraint
{
public $message = 'Sorry, your message looks like spam';
public $message = 'fos_user.body.spam';

public function validatedBy()
{
Expand Down

0 comments on commit fdc9e1b

Please sign in to comment.