(context, request, execution)
| 144 | } |
| 145 | |
| 146 | function validate (context, request, execution) { |
| 147 | const runExecution = execution === undefined |
| 148 | |
| 149 | if (runExecution || !execution.skipParams) { |
| 150 | const params = validateParam(context[paramsSchema], request, 'params') |
| 151 | if (params) { |
| 152 | if (typeof params.then !== 'function') { |
| 153 | return wrapValidationError(params, 'params', context.schemaErrorFormatter) |
| 154 | } else { |
| 155 | return validateAsyncParams(params, context, request) |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | if (runExecution || !execution.skipBody) { |
| 161 | let validatorFunction = null |
| 162 | if (typeof context[bodySchema] === 'function') { |
| 163 | validatorFunction = context[bodySchema] |
| 164 | } else if (context[bodySchema]) { |
| 165 | const contentSchema = context[bodySchema][request.mediaType] |
| 166 | if (contentSchema) { |
| 167 | validatorFunction = contentSchema |
| 168 | } |
| 169 | } |
| 170 | const body = validateParam(validatorFunction, request, 'body') |
| 171 | if (body) { |
| 172 | if (typeof body.then !== 'function') { |
| 173 | return wrapValidationError(body, 'body', context.schemaErrorFormatter) |
| 174 | } else { |
| 175 | return validateAsyncBody(body, context, request) |
| 176 | } |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | if (runExecution || !execution.skipQuery) { |
| 181 | const query = validateParam(context[querystringSchema], request, 'query') |
| 182 | if (query) { |
| 183 | if (typeof query.then !== 'function') { |
| 184 | return wrapValidationError(query, 'querystring', context.schemaErrorFormatter) |
| 185 | } else { |
| 186 | return validateAsyncQuery(query, context, request) |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | const headers = validateParam(context[headersSchema], request, 'headers') |
| 192 | if (headers) { |
| 193 | if (typeof headers.then !== 'function') { |
| 194 | return wrapValidationError(headers, 'headers', context.schemaErrorFormatter) |
| 195 | } else { |
| 196 | return validateAsyncHeaders(headers, context, request) |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | return false |
| 201 | } |
| 202 | |
| 203 | function validateAsyncParams (validatePromise, context, request) { |
no test coverage detected