Skip to content

Commit 0f7b872

Browse files
committed
Update readme and return object when emtpty
1 parent cebacd0 commit 0f7b872

File tree

3 files changed

+25
-22
lines changed

3 files changed

+25
-22
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Validate
2+
3+
```js
4+
const { validate, email, length } = require('validate')
5+
6+
const rules = {
7+
fields: {
8+
email: {
9+
validator: () => {
10+
return email(value) && length(value, { max: 75 })
11+
},
12+
},
13+
password: {
14+
validator: () => {
15+
return length(value, { min: 18, max: 45 })
16+
},
17+
}
18+
}
19+
}
20+
21+
const { valid } = validate(fields, {
22+
rules,
23+
})
24+
```

REAMD.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/validate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function validate (fields, { rules }) {
22
if (isEmpty(fields)) {
3-
return false
3+
return { valid: false, results: [] }
44
}
55

66
const checked = []

0 commit comments

Comments
 (0)