Skip to content

Commit 90955ea

Browse files
committed
docs: update validation rules whit field label
1 parent 7092f7d commit 90955ea

File tree

1 file changed

+36
-24
lines changed

1 file changed

+36
-24
lines changed

docs/customization.md

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -95,35 +95,47 @@ Shield has the following rules for registration:
9595

9696
```php
9797
[
98-
'username' => [
99-
'required',
100-
'max_length[30]',
101-
'min_length[3]',
102-
'regex_match[/\A[a-zA-Z0-9\.]+\z/]',
103-
'is_unique[users.username]',
104-
],
105-
'email' => 'required|max_length[254]|valid_email|is_unique[auth_identities.secret]',
106-
'password' => 'required|strong_password',
107-
'password_confirm' => 'required|matches[password]',
98+
'username' => [
99+
'label' => 'Auth.username',
100+
'rules' => 'required|max_length[30]|min_length[3]|regex_match[/\A[a-zA-Z0-9\.]+\z/]|is_unique[users.username]',
101+
],
102+
'email' => [
103+
'label' => 'Auth.email',
104+
'rules' => 'required|max_length[254]|valid_email|is_unique[auth_identities.secret]',
105+
],
106+
'password' => [
107+
'label' => 'Auth.password',
108+
'rules' => 'required|strong_password',
109+
],
110+
'password_confirm' => [
111+
'label' => 'Auth.passwordConfirm',
112+
'rules' => 'required|matches[password]',
113+
],
108114
];
109115
```
110116

111117
If you need a different set of rules for registration, you can specify them in your `Validation` configuration (**app/Config/Validation.php**) like:
112118

113119
```php
114-
//--------------------------------------------------------------------
115-
// Rules
116-
//--------------------------------------------------------------------
117-
public $registration = [
118-
'username' => [
119-
'required',
120-
'max_length[30]',
121-
'min_length[3]',
122-
'regex_match[/\A[a-zA-Z0-9\.]+\z/]',
123-
'is_unique[users.username]',
120+
//--------------------------------------------------------------------
121+
// Rules
122+
//--------------------------------------------------------------------
123+
public $registration = [
124+
'username' => [
125+
'label' => 'Auth.username',
126+
'rules' => 'required|max_length[30]|min_length[3]|regex_match[/\A[a-zA-Z0-9\.]+\z/]|is_unique[users.username]',
124127
],
125-
'email' => 'required|max_length[254]|valid_email|is_unique[auth_identities.secret]',
126-
'password' => 'required|strong_password',
127-
'password_confirm' => 'required|matches[password]',
128-
];
128+
'email' => [
129+
'label' => 'Auth.email',
130+
'rules' => 'required|max_length[254]|valid_email|is_unique[auth_identities.secret]',
131+
],
132+
'password' => [
133+
'label' => 'Auth.password',
134+
'rules' => 'required|strong_password',
135+
],
136+
'password_confirm' => [
137+
'label' => 'Auth.passwordConfirm',
138+
'rules' => 'required|matches[password]',
139+
],
140+
];
129141
```

0 commit comments

Comments
 (0)