Skip to content

Commit

Permalink
Add validation groups to all constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Aug 10, 2023
1 parent 594a572 commit 520679e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,27 @@
<option name="fields">username</option>
<option name="errorPath">username</option>
<option name="message">nucleos_user.username.already_used</option>
<option name="groups">
<value>User</value>
</option>
</constraint>
<constraint name="Doctrine\Bundle\MongoDBBundle\Validator\Constraints\Unique">
<option name="fields">email</option>
<option name="errorPath">email</option>
<option name="message">nucleos_user.email.already_used</option>
<option name="groups">
<value>User</value>
</option>
</constraint>
</class>
<class name="Nucleos\UserBundle\Model\Group">
<constraint name="Doctrine\Bundle\MongoDBBundle\Validator\Constraints\Unique">
<option name="fields">name</option>
<option name="errorPath">name</option>
<option name="message">nucleos_group.name.already_used</option>
<option name="groups">
<value>Group</value>
</option>
</constraint>
</class>
</constraint-mapping>
9 changes: 9 additions & 0 deletions src/Resources/config/storage-validation/orm/validation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,27 @@
<option name="fields">username</option>
<option name="errorPath">username</option>
<option name="message">nucleos_user.username.already_used</option>
<option name="groups">
<value>User</value>
</option>
</constraint>
<constraint name="Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity">
<option name="fields">email</option>
<option name="errorPath">email</option>
<option name="message">nucleos_user.email.already_used</option>
<option name="groups">
<value>User</value>
</option>
</constraint>
</class>
<class name="Nucleos\UserBundle\Model\Group">
<constraint name="Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity">
<option name="fields">name</option>
<option name="errorPath">name</option>
<option name="message">nucleos_group.name.already_used</option>
<option name="groups">
<value>Group</value>
</option>
</constraint>
</class>
</constraint-mapping>
23 changes: 23 additions & 0 deletions src/Resources/config/validation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,49 @@
<property name="username">
<constraint name="NotBlank">
<option name="message">nucleos_user.username.blank</option>
<option name="groups">
<value>User</value>
</option>
</constraint>
<constraint name="Length">
<option name="min">2</option>
<option name="minMessage">nucleos_user.username.short</option>
<option name="max">180</option>
<option name="maxMessage">nucleos_user.username.long</option>
<option name="groups">
<value>User</value>
</option>
</constraint>
</property>
<property name="email">
<constraint name="NotBlank">
<option name="message">nucleos_user.email.blank</option>
<option name="groups">
<value>User</value>
</option>
</constraint>
<constraint name="Length">
<option name="min">2</option>
<option name="minMessage">nucleos_user.email.short</option>
<option name="max">180</option>
<option name="maxMessage">nucleos_user.email.long</option>
<option name="groups">
<value>User</value>
</option>
</constraint>
<constraint name="Email">
<option name="message">nucleos_user.email.invalid</option>
<option name="groups">
<value>User</value>
</option>
</constraint>
</property>
<property name="plainPassword">
<constraint name="NotBlank">
<option name="message">nucleos_user.password.blank</option>
<option name="groups">
<value>ResetPassword</value>
<value>User</value>
</option>
</constraint>
<constraint name="Length">
Expand All @@ -40,6 +56,7 @@
<option name="groups">
<value>ResetPassword</value>
<value>UpdateSecurity</value>
<value>User</value>
</option>
</constraint>
</property>
Expand All @@ -48,12 +65,18 @@
<property name="name">
<constraint name="NotBlank">
<option name="message">nucleos_user.group.blank</option>
<option name="groups">
<value>Group</value>
</option>
</constraint>
<constraint name="Length">
<option name="min">2</option>
<option name="minMessage">nucleos_user.group.short</option>
<option name="max">180</option>
<option name="maxMessage">nucleos_user.group.long</option>
<option name="groups">
<value>Group</value>
</option>
</constraint>
</property>
</class>
Expand Down

0 comments on commit 520679e

Please sign in to comment.