Skip to content

Commit c7e4377

Browse files
committed
Merge branch 'development'
2 parents 9b89f1c + 66a6772 commit c7e4377

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

hapijoi/sync.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env node
2+
const Joi = require("joi");
3+
4+
const schema = Joi.object().keys({
5+
username: Joi.string().required(),
6+
email: Joi.string().email().required()
7+
});
8+
9+
let username = "Roger Brown";
10+
let email = "roger@example";
11+
let correct = "[email protected]";
12+
13+
let data = { username, email };
14+
console.log(data);
15+
let correctData = { username: username, email: correct };
16+
console.log(correctData);
17+
18+
let {error, value} = schema.validate(data);
19+
console.error(error);
20+
console.log(value);
21+
let {err, val} = schema.validate(correctData);
22+
if (err) {
23+
console.error(err);
24+
console.log(val);
25+
}
26+
27+
async function main() {
28+
try {
29+
await schema.validateAsync(data);
30+
}
31+
catch (err) {
32+
console.error(err.message);
33+
}
34+
try {
35+
await schema.validateAsync(correctData);
36+
}
37+
catch (err) {
38+
console.error(err.message);
39+
}
40+
}
41+
42+
main();

hapijoi/version.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env node
2+
const Joi = require("@hapi/joi");
3+
4+
console.log(Joi.version);

0 commit comments

Comments
 (0)