Skip to content

Commit 7cbc328

Browse files
authored
Merge pull request #82 from Kavinkumar07/master
[Kavin] #71 | Fixed Validator throws Cannot read property 'xxx' of nu…
2 parents e7b59c9 + 4caa259 commit 7cbc328

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/validator.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ class Validator {
244244
keySplit.map((item) => {
245245
if (typeof value === 'undefined') {
246246
value = this.inputs[item];
247+
} else if (!value) {
248+
return value;
247249
} else {
248250
value = value[item];
249251
}

test/edge.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ describe('Edge Cases', () => {
2828
});
2929

3030
it('should reject null and required fields', async () => {
31-
const v = new Validator({ field: null }, { field: 'required|string' });
31+
const v = new Validator({ field: null }, {
32+
field: 'required|object',
33+
'field.id': 'required|string'
34+
});
3235

3336
const matched = await v.check();
3437
assert.equal(matched, false);

0 commit comments

Comments
 (0)