Skip to content

Commit

Permalink
fix(Config Schema): Revert invalid "oneOf" based validation
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Oct 9, 2020
1 parent 2e26e07 commit a9b28b6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
16 changes: 10 additions & 6 deletions lib/plugins/aws/package/compile/events/cloudWatchEvent/index.js
Expand Up @@ -35,12 +35,6 @@ class AwsCompileCloudWatchEventEvents {
name: { type: 'string', pattern: '[a-zA-Z0-9-_.]+', minLength: 1, maxLength: 64 },
enabled: { type: 'boolean' },
},
oneOf: [
{ required: ['input'] },
{ required: ['inputPath'] },
{ required: ['inputTransformer'] },
{ required: [] },
],
additionalProperties: false,
});
}
Expand Down Expand Up @@ -69,6 +63,16 @@ class AwsCompileCloudWatchEventEvents {
Input = event.cloudwatchEvent.input;
InputTransformer = event.cloudwatchEvent.inputTransformer;

if ([Input, InputPath, InputTransformer].filter(Boolean).length > 1) {
throw new this.serverless.classes.Error(
[
'You can only set one of input, inputPath, or inputTransformer ',
'properties at the same time for cloudwatch events. ',
'Please check the AWS docs for more info',
].join('')
);
}

if (Input && typeof Input === 'object') {
Input = JSON.stringify(Input);
}
Expand Down
21 changes: 10 additions & 11 deletions lib/plugins/aws/package/compile/events/eventBridge/index.js
Expand Up @@ -49,17 +49,7 @@ class AwsCompileEventBridgeEvents {
additionalProperties: false,
},
},
allOf: [
{ anyOf: [{ required: ['pattern'] }, { required: ['schedule'] }] },
{
oneOf: [
{ required: [] },
{ required: ['input'] },
{ required: ['inputPath'] },
{ required: ['inputTransformer'] },
],
},
],
anyOf: [{ required: ['pattern'] }, { required: ['schedule'] }],
});
}

Expand Down Expand Up @@ -105,6 +95,15 @@ class AwsCompileEventBridgeEvents {
idx
);

if ([Input, InputPath, InputTransformer].filter(Boolean).length > 1) {
throw new this.serverless.classes.Error(
[
'You can only set one of input, inputPath, or inputTransformer ',
'properties for eventBridge events.',
].join('')
);
}

if (InputTransformer) {
InputTransformer = _.mapKeys(
InputTransformer,
Expand Down
5 changes: 0 additions & 5 deletions lib/plugins/aws/provider/awsProvider.js
Expand Up @@ -555,11 +555,6 @@ class AwsProvider {
role: { $ref: '#/definitions/awsArn' },
roleManagedExternally: { type: 'boolean' },
},
oneOf: [
{ required: [] },
{ required: ['role'] },
{ required: ['roleManagedExternally'] },
],
additionalProperties: false,
},
],
Expand Down

0 comments on commit a9b28b6

Please sign in to comment.