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