Skip to content

Commit 2b31f6f

Browse files
Update README.md
1 parent 427c504 commit 2b31f6f

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,16 @@ $data = [
125125
[
126126
'name' => 'abc xyz',
127127
'gender' => 'male',
128-
'email' => '[email protected]'
128+
'contact' => [
129+
'email' => '[email protected]'
130+
]
129131
],
130132
[
131133
'name' => 'xyz abc',
132134
'gender' => 'male',
133-
'email' => '[email protected]'
135+
'contact' => [
136+
'email' => '[email protected]'
137+
]
134138
]
135139
];
136140

@@ -146,12 +150,20 @@ $validator->rules([
146150
'lowercase' => true,
147151
'in' => ['male', 'female', 'other']
148152
],
149-
'email' => [
153+
'contact.email' => [
150154
'required' => true,
151155
'email' => true,
152156
]
153157
]);
154158

159+
//Set validation messages
160+
$validator->messages([
161+
'contact.email' => [
162+
'required' => 'Please enter email address.',
163+
'email' => 'Please enter valid email address.'
164+
]
165+
]);
166+
155167
//Validate multiple sets of data
156168
if($validator->validate($data, true)) {
157169
//Ok data is valid

0 commit comments

Comments
 (0)