Changeset View
Changeset View
Standalone View
Standalone View
keyserver/src/utils/validation-utils.js
Show First 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | ): I { | ||||
// to change `input` flow type | // to change `input` flow type | ||||
const TValidator = typesToConvert[typesToConvert.indexOf(validator)]; | const TValidator = typesToConvert[typesToConvert.indexOf(validator)]; | ||||
if (TValidator && TValidator.is(input)) { | if (TValidator && TValidator.is(input)) { | ||||
const TInput = assertWithValidator(input, TValidator); | const TInput = assertWithValidator(input, TValidator); | ||||
const converted = conversionFunction(TInput); | const converted = conversionFunction(TInput); | ||||
return assertWithValidator(converted, validator); | return assertWithValidator(converted, validator); | ||||
} | } | ||||
if (validator.meta.kind === 'maybe') { | if (validator.meta.kind === 'maybe' || validator.meta.kind === 'subtype') { | ||||
return convertObject( | return convertObject( | ||||
validator.meta.type, | validator.meta.type, | ||||
input, | input, | ||||
typesToConvert, | typesToConvert, | ||||
conversionFunction, | conversionFunction, | ||||
); | ); | ||||
} | } | ||||
if (validator.meta.kind === 'interface' && typeof input === 'object') { | if (validator.meta.kind === 'interface' && typeof input === 'object') { | ||||
▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines |