Skip to content

Commit

Permalink
fix(forms): minLength do not fail when field is empty
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #469
  • Loading branch information
henri-hulski committed Nov 28, 2016
1 parent fe8128f commit 54aa94a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/cerebral-forms/src/rules.js
Expand Up @@ -64,7 +64,7 @@ const rules = {
return value.length <= length
},
minLength (value, form, length) {
return value.length >= length
return !rules.isExisty(value) || rules.isEmpty(value) || value.length >= length
}
}

Expand Down
4 changes: 4 additions & 0 deletions packages/cerebral-forms/src/rules.test.js
Expand Up @@ -339,5 +339,9 @@ describe('rules', () => {
it('should return true due to length > 4', () => {
assert.equal(rules.minLength('some1', null, 4), true)
})

it('should return true due to empty field', () => {
assert.equal(rules.minLength('', null, 4), true)
})
})
})

0 comments on commit 54aa94a

Please sign in to comment.