+1
-0
@@ -5,2 +5,3 @@ 'use strict'; | ||
| mixed: { | ||
| 'default': '${path} is invalid', | ||
| notType: '${path} (value: `${value}`) must be a `${type}` type', | ||
@@ -7,0 +8,0 @@ required: '${path} is a required field', |
+11
-3
@@ -237,3 +237,3 @@ 'use strict'; | ||
| errorMsg = formatError(opts.message); | ||
| errorMsg = formatError(opts.message || locale['default']); | ||
@@ -316,3 +316,4 @@ isExclusive = opts.name && next._exclusive[opts.name] === true; | ||
| var aliases = { | ||
| oneOf: ['equals'] | ||
| oneOf: ['equals', 'is'], | ||
| notOneOf: ['not', 'nope'] | ||
| }; | ||
@@ -332,2 +333,9 @@ | ||
| }); | ||
| } | ||
| } | ||
| // [{ value, exclude }] | ||
| // values.every(({ value, exclude }) => { | ||
| // var isEql = eql(value, otherval) | ||
| // return (exclude && !isEql) || isEql | ||
| // }) |
+2
-2
@@ -76,7 +76,7 @@ 'use strict'; | ||
| positive: function positive(max, msg) { | ||
| positive: function positive(msg) { | ||
| return this.min(0, msg || locale.positive); | ||
| }, | ||
| negative: function negative(max, msg) { | ||
| negative: function negative(msg) { | ||
| return this.max(0, msg || locale.negative); | ||
@@ -83,0 +83,0 @@ }, |
@@ -22,6 +22,8 @@ 'use strict'; | ||
| if (typeof options === 'function') this.fn = options;else { | ||
| if (!has(options, 'is')) throw new TypeError('.is must be provided'); | ||
| if (!options.then && !options.otherwise) throw new TypeError('.then or .otherwise must be provided'); | ||
| if (options.then && options.then._type !== type || options.otherwise && options.otherwise._type !== type) throw new TypeError('cannot return polymorphic conditionals'); | ||
| if (!has(options, 'is')) throw new TypeError('`is:` is required for `when()` conditions'); | ||
| if (!options.then && !options.otherwise) throw new TypeError('either `then:` or `otherwise:` is required for `when()` conditions'); | ||
| if (options.then && options.then._type !== type || options.otherwise && options.otherwise._type !== type) throw new TypeError('cannot create polymorphic conditionals, `then` and `otherwise` must be the same type: ' + type); | ||
| is = typeof is === 'function' ? is : (function (is, value) { | ||
@@ -28,0 +30,0 @@ return is === value; |
+1
-1
| { | ||
| "name": "yup", | ||
| "version": "0.7.2", | ||
| "version": "0.7.3", | ||
| "description": "Dead simple Object schema validation", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
+1
-0
@@ -5,2 +5,3 @@ | ||
| mixed: { | ||
| default: '${path} is invalid', | ||
| notType: '${path} (value: `${value}`) must be a `${type}` type', | ||
@@ -7,0 +8,0 @@ required: '${path} is a required field', |
+10
-2
@@ -225,3 +225,3 @@ 'use strict'; | ||
| errorMsg = formatError(opts.message) | ||
| errorMsg = formatError(opts.message || locale.default) | ||
@@ -304,3 +304,4 @@ isExclusive = opts.name && next._exclusive[opts.name] === true | ||
| var aliases = { | ||
| oneOf: ['equals'] | ||
| oneOf: ['equals', 'is'], | ||
| notOneOf: ['not', 'nope'] | ||
| } | ||
@@ -318,1 +319,8 @@ | ||
| } | ||
| // [{ value, exclude }] | ||
| // values.every(({ value, exclude }) => { | ||
| // var isEql = eql(value, otherval) | ||
| // return (exclude && !isEql) || isEql | ||
| // }) |
+2
-2
@@ -48,7 +48,7 @@ 'use strict'; | ||
| positive(max, msg) { | ||
| positive(msg) { | ||
| return this.min(0, msg || locale.positive) | ||
| }, | ||
| negative(max, msg) { | ||
| negative(msg) { | ||
| return this.max(0, msg || locale.negative) | ||
@@ -55,0 +55,0 @@ }, |
@@ -17,6 +17,10 @@ 'use strict'; | ||
| { | ||
| if( !has(options, 'is') ) throw new TypeError('.is must be provided') | ||
| if( !options.then && !options.otherwise ) throw new TypeError('.then or .otherwise must be provided') | ||
| if( !has(options, 'is') ) | ||
| throw new TypeError('`is:` is required for `when()` conditions') | ||
| if( !options.then && !options.otherwise ) | ||
| throw new TypeError('either `then:` or `otherwise:` is required for `when()` conditions') | ||
| if( options.then && options.then._type !== type || options.otherwise && options.otherwise._type !== type) | ||
| throw new TypeError('cannot return polymorphic conditionals') | ||
| throw new TypeError(`cannot create polymorphic conditionals, \`then\` and \`otherwise\` must be the same type: ${type}`) | ||
@@ -23,0 +27,0 @@ is = typeof is === 'function' |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
148945
0.48%3259
0.46%