joi 4.8.1 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.c9/metadata/tab0 +1 -1
- package/.c9/metadata/workspace/.travis.yml +1 -0
- package/.c9/metadata/workspace/Makefile +1 -1
- package/.c9/metadata/workspace/README.md +1 -1
- package/.c9/metadata/workspace/lib/any.js +1 -0
- package/.c9/metadata/workspace/lib/binary.js +1 -0
- package/.c9/metadata/workspace/lib/boolean.js +1 -0
- package/.c9/metadata/workspace/lib/cast.js +1 -0
- package/.c9/metadata/workspace/lib/date.js +1 -1
- package/.c9/metadata/workspace/lib/function.js +1 -0
- package/.c9/metadata/workspace/lib/object.js +1 -0
- package/.c9/metadata/workspace/test/alternatives.js +1 -1
- package/.c9/metadata/workspace/test/array.js +1 -1
- package/.c9/metadata/workspace/test/index.js +1 -1
- package/.c9/metadata/workspace/test/ref.js +1 -1
- package/.travis.yml +1 -0
- package/Makefile +3 -3
- package/README.md +11 -0
- package/lib/language.js +2 -1
- package/lib/object.js +16 -0
- package/package.json +1 -1
- package/test/alternatives.js +5 -5
- package/test/any.js +10 -10
- package/test/array.js +11 -11
- package/test/binary.js +4 -4
- package/test/boolean.js +2 -2
- package/test/date.js +8 -8
- package/test/errors.js +7 -7
- package/test/index.js +67 -67
- package/test/number.js +6 -6
- package/test/object.js +107 -36
- package/test/ref.js +15 -15
- package/test/string.js +9 -9
package/test/binary.js
CHANGED
|
@@ -27,7 +27,7 @@ describe('binary', function () {
|
|
|
27
27
|
|
|
28
28
|
Joi.binary().validate('test', function (err, value) {
|
|
29
29
|
|
|
30
|
-
expect(err).to.not.exist;
|
|
30
|
+
expect(err).to.not.exist();
|
|
31
31
|
expect(value instanceof Buffer).to.equal(true);
|
|
32
32
|
expect(value.length).to.equal(4);
|
|
33
33
|
expect(value.toString('utf8')).to.equal('test');
|
|
@@ -56,7 +56,7 @@ describe('binary', function () {
|
|
|
56
56
|
|
|
57
57
|
Joi.binary().validate(5, function (err, value) {
|
|
58
58
|
|
|
59
|
-
expect(err).to.exist;
|
|
59
|
+
expect(err).to.exist();
|
|
60
60
|
expect(err.message).to.equal('value must be a buffer or a string');
|
|
61
61
|
done();
|
|
62
62
|
});
|
|
@@ -70,7 +70,7 @@ describe('binary', function () {
|
|
|
70
70
|
|
|
71
71
|
Joi.binary().validate(new Buffer('hello world'), function (err, value) {
|
|
72
72
|
|
|
73
|
-
expect(err).to.not.exist;
|
|
73
|
+
expect(err).to.not.exist();
|
|
74
74
|
expect(value.toString('utf8')).to.equal('hello world');
|
|
75
75
|
done();
|
|
76
76
|
});
|
|
@@ -85,7 +85,7 @@ describe('binary', function () {
|
|
|
85
85
|
var input = new Buffer('abcdef');
|
|
86
86
|
schema.validate(input.toString('base64'), function (err, value) {
|
|
87
87
|
|
|
88
|
-
expect(err).to.not.exist;
|
|
88
|
+
expect(err).to.not.exist();
|
|
89
89
|
expect(value instanceof Buffer).to.equal(true);
|
|
90
90
|
expect(value.toString()).to.equal('abcdef');
|
|
91
91
|
done();
|
package/test/boolean.js
CHANGED
|
@@ -27,7 +27,7 @@ describe('boolean', function () {
|
|
|
27
27
|
|
|
28
28
|
Joi.boolean().validate('true', function (err, value) {
|
|
29
29
|
|
|
30
|
-
expect(err).to.not.exist;
|
|
30
|
+
expect(err).to.not.exist();
|
|
31
31
|
expect(value).to.equal(true);
|
|
32
32
|
done();
|
|
33
33
|
});
|
|
@@ -37,7 +37,7 @@ describe('boolean', function () {
|
|
|
37
37
|
|
|
38
38
|
Joi.boolean().validate(1, function (err, value) {
|
|
39
39
|
|
|
40
|
-
expect(err).to.exist;
|
|
40
|
+
expect(err).to.exist();
|
|
41
41
|
expect(value).to.equal(1);
|
|
42
42
|
done();
|
|
43
43
|
});
|
package/test/date.js
CHANGED
|
@@ -37,7 +37,7 @@ describe('date', function () {
|
|
|
37
37
|
var now = Date.now();
|
|
38
38
|
Joi.date().valid(new Date(now)).validate(new Date(now), function (err, value) {
|
|
39
39
|
|
|
40
|
-
expect(err).to.not.exist;
|
|
40
|
+
expect(err).to.not.exist();
|
|
41
41
|
done();
|
|
42
42
|
});
|
|
43
43
|
});
|
|
@@ -46,7 +46,7 @@ describe('date', function () {
|
|
|
46
46
|
|
|
47
47
|
Joi.date().options({ convert: false }).validate('1-1-2013 UTC', function (err, value) {
|
|
48
48
|
|
|
49
|
-
expect(err).to.exist;
|
|
49
|
+
expect(err).to.exist();
|
|
50
50
|
expect(err.message).to.equal('value must be a number of milliseconds or valid date string');
|
|
51
51
|
done();
|
|
52
52
|
});
|
|
@@ -56,7 +56,7 @@ describe('date', function () {
|
|
|
56
56
|
|
|
57
57
|
Joi.date().validate(new Date(), function (err, value) {
|
|
58
58
|
|
|
59
|
-
expect(err).to.not.exist;
|
|
59
|
+
expect(err).to.not.exist();
|
|
60
60
|
done();
|
|
61
61
|
});
|
|
62
62
|
});
|
|
@@ -68,7 +68,7 @@ describe('date', function () {
|
|
|
68
68
|
|
|
69
69
|
Joi.date().validate(mili.toString(), function (err, value) {
|
|
70
70
|
|
|
71
|
-
expect(err).to.not.exist;
|
|
71
|
+
expect(err).to.not.exist();
|
|
72
72
|
expect(value).to.deep.equal(now);
|
|
73
73
|
done();
|
|
74
74
|
});
|
|
@@ -80,7 +80,7 @@ describe('date', function () {
|
|
|
80
80
|
|
|
81
81
|
Joi.date().min('now').validate(future, function (err, value) {
|
|
82
82
|
|
|
83
|
-
expect(err).to.not.exist;
|
|
83
|
+
expect(err).to.not.exist();
|
|
84
84
|
expect(value).to.deep.equal(future);
|
|
85
85
|
done();
|
|
86
86
|
});
|
|
@@ -92,7 +92,7 @@ describe('date', function () {
|
|
|
92
92
|
|
|
93
93
|
Joi.date().min('now').validate(past, function (err, value) {
|
|
94
94
|
|
|
95
|
-
expect(err).to.exist;
|
|
95
|
+
expect(err).to.exist();
|
|
96
96
|
done();
|
|
97
97
|
});
|
|
98
98
|
});
|
|
@@ -103,7 +103,7 @@ describe('date', function () {
|
|
|
103
103
|
|
|
104
104
|
Joi.date().max('now').validate(past, function (err, value) {
|
|
105
105
|
|
|
106
|
-
expect(err).to.not.exist;
|
|
106
|
+
expect(err).to.not.exist();
|
|
107
107
|
expect(value).to.deep.equal(past);
|
|
108
108
|
done();
|
|
109
109
|
});
|
|
@@ -115,7 +115,7 @@ describe('date', function () {
|
|
|
115
115
|
|
|
116
116
|
Joi.date().max('now').validate(future, function (err, value) {
|
|
117
117
|
|
|
118
|
-
expect(err).to.exist;
|
|
118
|
+
expect(err).to.exist();
|
|
119
119
|
done();
|
|
120
120
|
});
|
|
121
121
|
});
|
package/test/errors.js
CHANGED
|
@@ -72,7 +72,7 @@ describe('errors', function () {
|
|
|
72
72
|
|
|
73
73
|
Joi.validate(input, schema, { abortEarly: false, language: lang }, function (err, value) {
|
|
74
74
|
|
|
75
|
-
expect(err).to.exist;
|
|
75
|
+
expect(err).to.exist();
|
|
76
76
|
expect(err.name).to.equal('ValidationError');
|
|
77
77
|
expect(err.message).to.equal('value 11. required 7. xor 7. email 19. date 18. alphanum 16. min 14. max 15. notEmpty 3');
|
|
78
78
|
done();
|
|
@@ -122,7 +122,7 @@ describe('errors', function () {
|
|
|
122
122
|
|
|
123
123
|
Joi.validate(input, schema, { abortEarly: false }, function (err, value) {
|
|
124
124
|
|
|
125
|
-
expect(err).to.exist;
|
|
125
|
+
expect(err).to.exist();
|
|
126
126
|
expect(err.details).to.have.length(3);
|
|
127
127
|
expect(err.details[0].type).to.equal('number.base');
|
|
128
128
|
expect(err.details[1].type).to.equal('string.base');
|
|
@@ -141,7 +141,7 @@ describe('errors', function () {
|
|
|
141
141
|
|
|
142
142
|
schema.validate(input, function (err, value) {
|
|
143
143
|
|
|
144
|
-
expect(err).to.exist;
|
|
144
|
+
expect(err).to.exist();
|
|
145
145
|
expect(err.details[0].path).to.equal('1.1.x');
|
|
146
146
|
done();
|
|
147
147
|
});
|
|
@@ -157,7 +157,7 @@ describe('errors', function () {
|
|
|
157
157
|
|
|
158
158
|
schema.validate(input, function (err, value) {
|
|
159
159
|
|
|
160
|
-
expect(err).to.exist;
|
|
160
|
+
expect(err).to.exist();
|
|
161
161
|
expect(err.details[0].path).to.equal('1.1');
|
|
162
162
|
done();
|
|
163
163
|
});
|
|
@@ -175,7 +175,7 @@ describe('errors', function () {
|
|
|
175
175
|
|
|
176
176
|
Joi.validate(input, schema, function (err, value) {
|
|
177
177
|
|
|
178
|
-
expect(err).to.exist;
|
|
178
|
+
expect(err).to.exist();
|
|
179
179
|
expect(err.details[0].path).to.equal('x.1.x');
|
|
180
180
|
done();
|
|
181
181
|
});
|
|
@@ -226,7 +226,7 @@ describe('errors', function () {
|
|
|
226
226
|
|
|
227
227
|
Joi.validate(object, schema, { abortEarly: false }, function (err, value) {
|
|
228
228
|
|
|
229
|
-
expect(err).to.exist;
|
|
229
|
+
expect(err).to.exist();
|
|
230
230
|
expect(err.annotate()).to.equal('{\n \"y\": {\n \"b\" \u001b[31m[1]\u001b[0m: {\n \"c\": 10\n },\n \u001b[41m\"u\"\u001b[0m\u001b[31m [2]: -- missing --\u001b[0m\n },\n \"a\" \u001b[31m[3]\u001b[0m: \"m\"\n}\n\u001b[31m\n[1] a must be one of a, b, c, d\n[2] u is required\n[3] b must be a string\u001b[0m');
|
|
231
231
|
done();
|
|
232
232
|
});
|
|
@@ -244,7 +244,7 @@ describe('errors', function () {
|
|
|
244
244
|
|
|
245
245
|
Joi.validate({ x: true }, schema, function (err, value) {
|
|
246
246
|
|
|
247
|
-
expect(err).to.exist;
|
|
247
|
+
expect(err).to.exist();
|
|
248
248
|
expect(err.annotate()).to.equal('{\n \"x\" \u001b[31m[1, 2, 3]\u001b[0m: true\n}\n\u001b[31m\n[1] x must be a string\n[2] x must be a number\n[3] x must be a number of milliseconds or valid date string\u001b[0m');
|
|
249
249
|
done();
|
|
250
250
|
});
|