Skip to content

Commit 6d3e599

Browse files
committed
Add retvals
1 parent 66a6772 commit 6d3e599

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

hapijoi/retvals.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env node
2+
const Joi = require("joi");
3+
4+
const schema = Joi.object().keys({
5+
username: Joi.string().required(),
6+
born: Joi.date().required()
7+
});
8+
9+
let username = "Roger Brown";
10+
let born = "1988-12-11";
11+
12+
let data = { username, born };
13+
14+
const { err, value } = schema.validate(data);
15+
16+
if (err) {
17+
console.log(err.details);
18+
} else {
19+
console.log(value);
20+
}

0 commit comments

Comments
 (0)