mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-17 01:17:29 +02:00
Use joi instead of assert
This commit is contained in:
parent
9eed7a0601
commit
a9ee3a09a8
10
lib/user.js
10
lib/user.js
@ -1,11 +1,17 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const gravatar = require('gravatar');
|
const gravatar = require('gravatar');
|
||||||
const assert = require('assert');
|
const Joi = require('joi');
|
||||||
|
|
||||||
module.exports = class User {
|
module.exports = class User {
|
||||||
constructor({ name, email, imageUrl } = {}) {
|
constructor({ name, email, imageUrl } = {}) {
|
||||||
assert(email, 'Email is required');
|
Joi.assert(
|
||||||
|
email,
|
||||||
|
Joi.string()
|
||||||
|
.email()
|
||||||
|
.required(),
|
||||||
|
'Email'
|
||||||
|
);
|
||||||
this.email = email;
|
this.email = email;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.imageUrl =
|
this.imageUrl =
|
||||||
|
@ -18,7 +18,7 @@ test('should require email', t => {
|
|||||||
const user = new User(); // eslint-disable-line
|
const user = new User(); // eslint-disable-line
|
||||||
}, Error);
|
}, Error);
|
||||||
|
|
||||||
t.is(error.message, 'Email is required');
|
t.is(error.message, 'Email "value" is required');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Should create user with only email defined', t => {
|
test('Should create user with only email defined', t => {
|
||||||
|
@ -56,7 +56,6 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"assert": "^1.4.1",
|
|
||||||
"async": "^2.1.5",
|
"async": "^2.1.5",
|
||||||
"body-parser": "^1.18.2",
|
"body-parser": "^1.18.2",
|
||||||
"commander": "^2.9.0",
|
"commander": "^2.9.0",
|
||||||
|
16
yarn.lock
16
yarn.lock
@ -298,12 +298,6 @@ assert-plus@^0.2.0:
|
|||||||
version "0.2.0"
|
version "0.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234"
|
resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234"
|
||||||
|
|
||||||
assert@^1.4.1:
|
|
||||||
version "1.4.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/assert/-/assert-1.4.1.tgz#99912d591836b5a6f5b345c0f07eefc08fc65d91"
|
|
||||||
dependencies:
|
|
||||||
util "0.10.3"
|
|
||||||
|
|
||||||
ast-types@0.x.x:
|
ast-types@0.x.x:
|
||||||
version "0.9.14"
|
version "0.9.14"
|
||||||
resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.14.tgz#d34ba5dffb9d15a44351fd2a9d82e4ab2838b5ba"
|
resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.14.tgz#d34ba5dffb9d15a44351fd2a9d82e4ab2838b5ba"
|
||||||
@ -2690,10 +2684,6 @@ inherits@2, inherits@2.0.3, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.0, i
|
|||||||
version "2.0.3"
|
version "2.0.3"
|
||||||
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
|
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
|
||||||
|
|
||||||
inherits@2.0.1:
|
|
||||||
version "2.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1"
|
|
||||||
|
|
||||||
ini@^1.3.4, ini@~1.3.0:
|
ini@^1.3.4, ini@~1.3.0:
|
||||||
version "1.3.4"
|
version "1.3.4"
|
||||||
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e"
|
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e"
|
||||||
@ -5838,12 +5828,6 @@ util-deprecate@~1.0.1:
|
|||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
|
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
|
||||||
|
|
||||||
util@0.10.3:
|
|
||||||
version "0.10.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9"
|
|
||||||
dependencies:
|
|
||||||
inherits "2.0.1"
|
|
||||||
|
|
||||||
utile@0.3.x:
|
utile@0.3.x:
|
||||||
version "0.3.0"
|
version "0.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/utile/-/utile-0.3.0.tgz#1352c340eb820e4d8ddba039a4fbfaa32ed4ef3a"
|
resolved "https://registry.yarnpkg.com/utile/-/utile-0.3.0.tgz#1352c340eb820e4d8ddba039a4fbfaa32ed4ef3a"
|
||||||
|
Loading…
Reference in New Issue
Block a user