-
-
Save Ashoat/45893e511ab9e860e351d08307ec3ef7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/keyserver/src/utils/validation-utils.js b/keyserver/src/utils/validation-utils.js | |
index 1415cfd24..87a75b188 100644 | |
--- a/keyserver/src/utils/validation-utils.js | |
+++ b/keyserver/src/utils/validation-utils.js | |
@@ -2,7 +2,7 @@ | |
import _mapKeys from 'lodash/fp/mapKeys.js'; | |
import _mapValues from 'lodash/fp/mapValues.js'; | |
-import type { TType } from 'tcomb'; | |
+import type { TType, TInterface } from 'tcomb'; | |
import type { PolicyType } from 'lib/facts/policies.js'; | |
import { hasMinCodeVersion } from 'lib/shared/version-utils.js'; | |
@@ -144,7 +144,7 @@ function findFirstInputMatchingValidator( | |
return null; | |
} | |
-function convertObject<T, I: any>( | |
+function convertObject<T, I>( | |
validator: TType<I>, | |
input: I, | |
typesToConvert: $ReadOnlyArray<TType<T>>, | |
@@ -170,9 +170,10 @@ function convertObject<T, I: any>( | |
); | |
} | |
if (validator.meta.kind === 'interface' && typeof input === 'object') { | |
+ const recastValidator: TInterface<typeof input> = (validator: any); | |
const result = {}; | |
for (const key in input) { | |
- const innerValidator = validator.meta.props[key]; | |
+ const innerValidator = recastValidator.meta.props[key]; | |
result[key] = convertObject( | |
innerValidator, | |
input[key], | |
@@ -180,7 +181,7 @@ function convertObject<T, I: any>( | |
conversionFunction, | |
); | |
} | |
- return assertWithValidator(result, validator); | |
+ return assertWithValidator(result, recastValidator); | |
} | |
if (validator.meta.kind === 'union') { | |
for (const innerValidator of validator.meta.types) { | |
@@ -197,9 +198,9 @@ function convertObject<T, I: any>( | |
} | |
if (validator.meta.kind === 'list' && Array.isArray(input)) { | |
const innerValidator = validator.meta.type; | |
- return input.map(value => | |
+ return (input.map(value => | |
convertObject(innerValidator, value, typesToConvert, conversionFunction), | |
- ); | |
+ ): any); | |
} | |
if (validator.meta.kind === 'dict' && typeof input === 'object') { | |
const domainValidator = validator.meta.domain; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment