Skip to content

Commit ab6cf93

Browse files
authored
Merge pull request #353 from mulesoft/bugs/repeatable-headers-optional
empty array case added to validations. #151
2 parents f1dc750 + 7c7b51a commit ab6cf93

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
@@ -6311,14 +6311,15 @@ RAML.Inspector = (function() {
63116311
* @return {Object}
63126312
*/
63136313
return function (value, key, object) {
6314-
// Short-circuit validation if the value is `null`.
6315-
if (value == null) {
6316-
return toValidationObject(isOptional, 'required', value, key);
6317-
}
63186314

63196315
// Switch validation type depending on if the value is an array or not.
63206316
var isArray = Array.isArray(value);
63216317

6318+
// Short-circuit validation if empty value
6319+
if (value == null || (isArray && value.length === 0)) {
6320+
return toValidationObject(isOptional, 'required', value, key);
6321+
}
6322+
63226323
// Select the validation stack to use based on the (repeated) value.
63236324
var values = isArray ? value : [value];
63246325
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)