validate-fields-body
Advanced tools
Comparing version 1.1.2 to 1.1.3
{ | ||
"name": "validate-fields-body", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Validate-Fields-Body is a Javascript library for dealing with validation.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "tsc" | ||
}, | ||
@@ -23,3 +24,6 @@ "repository": { | ||
}, | ||
"homepage": "https://github.com/nerosengtianthr/validate-body-fields#readme" | ||
"homepage": "https://github.com/nerosengtianthr/validate-body-fields#readme", | ||
"devDependencies": { | ||
"typescript": "^4.9.5" | ||
} | ||
} |
@@ -17,4 +17,11 @@ # Validate-Fields-Body | ||
const fieldsValidate = ["username", "email", "password"]; | ||
const [isValid, logs, result] = useValidate(fieldsValidate, req.body); | ||
const poolBody = { | ||
username: "JohnDoe", | ||
email: "john@example.com", | ||
password: "1234", | ||
}; | ||
const [isValid, logs, result] = useValidate(fieldsValidate, poolBody); | ||
// isValid: return Boolean | ||
@@ -30,3 +37,12 @@ // logs: return Array | ||
// Required value in username and password | ||
const fieldsValidate = ["!username", "!password", "email"]; | ||
const poolBody = { | ||
username: "", | ||
email: "john@example.com", | ||
password: "", | ||
}; | ||
const [isValid, logs, result] = useValidate(fieldsValidate, req.body); | ||
@@ -46,3 +62,13 @@ | ||
// Matching Types : string number... | ||
const fieldsValidate = ["!username:string", "password:string", "age:number"]; | ||
const poolBody = { | ||
username: "johnDoe", | ||
email: "john@example.com", | ||
password: "123", | ||
age: 18, | ||
}; | ||
const [isValid, logs, result] = useValidate(fieldsValidate, req.body); | ||
@@ -49,0 +75,0 @@ |
7655
7
93
95
1