-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmin.js
More file actions
24 lines (20 loc) · 723 Bytes
/
min.js
File metadata and controls
24 lines (20 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var format = require("./lib/format")
var LIST_MESSAGE = "Expected %s to be at least %d characters long"
var NUMBER_MESSAGE = "Expected %s to be at least %d"
module.exports = min
function min(n, message) {
var listMessage = message || LIST_MESSAGE
var numberMessage = message || NUMBER_MESSAGE
return function validate(value, key) {
if (typeof value === "number") {
if (value < n || isNaN(value)) {
return {
message: format(numberMessage, key, n),
type: "min"
}
}
} else if (!value || value.length < n) {
return { message: format(listMessage, key, n), type: "min" }
}
}
}