Skip to content

Commit 26dd393

Browse files
author
Javier Isoldi
committed
empty array case added to validations. #151
1 parent 3f5a25d commit 26dd393

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

dist/scripts/api-console.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6263,14 +6263,15 @@ RAML.Inspector = (function() {
62636263
* @return {Object}
62646264
*/
62656265
return function (value, key, object) {
6266-
// Short-circuit validation if the value is `null`.
6267-
if (value == null) {
6268-
return toValidationObject(isOptional, 'required', value, key);
6269-
}
62706266

62716267
// Switch validation type depending on if the value is an array or not.
62726268
var isArray = Array.isArray(value);
62736269

6270+
// Short-circuit validation if empty value
6271+
if (value == null || (isArray && value.length === 0)) {
6272+
return toValidationObject(isOptional, 'required', value, key);
6273+
}
6274+
62746275
// Select the validation stack to use based on the (repeated) value.
62756276
var values = isArray ? value : [value];
62766277
var validations = isArray ? repeatValidations : simpleValidations;

src/vendor/raml-validate/raml-validate.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,15 @@
250250
* @return {Object}
251251
*/
252252
return function (value, key, object) {
253-
// Short-circuit validation if the value is `null`.
254-
if (value == null) {
255-
return toValidationObject(isOptional, 'required', value, key);
256-
}
257253

258254
// Switch validation type depending on if the value is an array or not.
259255
var isArray = Array.isArray(value);
260256

257+
// Short-circuit validation if empty value
258+
if (value == null || (isArray && value.length === 0)) {
259+
return toValidationObject(isOptional, 'required', value, key);
260+
}
261+
261262
// Select the validation stack to use based on the (repeated) value.
262263
var values = isArray ? value : [value];
263264
var validations = isArray ? repeatValidations : simpleValidations;

0 commit comments

Comments
 (0)