|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | 3 | const _ = require('lodash'); |
4 | | -const Joi = require('@hapi/joi'); |
| 4 | +const Joi = require('joi'); |
5 | 5 | const aslValidator = require('asl-validator'); |
6 | 6 | const BbPromise = require('bluebird'); |
7 | 7 | const crypto = require('crypto'); |
@@ -107,14 +107,17 @@ module.exports = { |
107 | 107 | } else { |
108 | 108 | Tags = toTags(this.serverless.service.provider.tags); |
109 | 109 | } |
110 | | - |
111 | | - const { error, value } = Joi.validate(stateMachineObj, schema, { allowUnknown: false }); |
112 | | - if (error) { |
113 | | - const errorMessage = `State machine [${stateMachineName}] is malformed. ` |
| 110 | + let validationValue; |
| 111 | + Joi.validate(stateMachineObj, schema, { allowUnknown: false }, (err, value) => { |
| 112 | + if (err) { |
| 113 | + const errorMessage = `State machine [${stateMachineName}] is malformed. ` |
114 | 114 | + 'Please check the README for more info. ' |
115 | | - + `${error}`; |
116 | | - throw new this.serverless.classes.Error(errorMessage); |
117 | | - } |
| 115 | + + `${err}`; |
| 116 | + throw new this.serverless.classes.Error(errorMessage); |
| 117 | + } else { |
| 118 | + validationValue = value; |
| 119 | + } |
| 120 | + }); |
118 | 121 |
|
119 | 122 | if (stateMachineObj.definition) { |
120 | 123 | if (this.serverless.service.stepFunctions.validate) { |
@@ -201,23 +204,23 @@ module.exports = { |
201 | 204 | _.forEach(stateMachineTags, tag => Tags.push(tag)); |
202 | 205 | } |
203 | 206 |
|
204 | | - if (value.loggingConfig) { |
205 | | - const Destinations = (value.loggingConfig.destinations || []) |
| 207 | + if (validationValue.loggingConfig) { |
| 208 | + const Destinations = (validationValue.loggingConfig.destinations || []) |
206 | 209 | .map(arn => ({ |
207 | 210 | CloudWatchLogsLogGroup: { |
208 | 211 | LogGroupArn: arn, |
209 | 212 | }, |
210 | 213 | })); |
211 | 214 | LoggingConfiguration = { |
212 | | - Level: value.loggingConfig.level, |
213 | | - IncludeExecutionData: value.loggingConfig.includeExecutionData, |
| 215 | + Level: validationValue.loggingConfig.level, |
| 216 | + IncludeExecutionData: validationValue.loggingConfig.includeExecutionData, |
214 | 217 | Destinations, |
215 | 218 | }; |
216 | 219 | } |
217 | 220 |
|
218 | | - if (value.tracingConfig) { |
| 221 | + if (validationValue.tracingConfig) { |
219 | 222 | TracingConfiguration = { |
220 | | - Enabled: value.tracingConfig.enabled, |
| 223 | + Enabled: validationValue.tracingConfig.enabled, |
221 | 224 | }; |
222 | 225 | } |
223 | 226 |
|
|
0 commit comments