Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
runtimeTypes.string.validate(input, context).chain(stringInput => {
const momentValue = moment(stringInput);
return momentValue.isValid()
? runtimeTypes.success(momentValue.valueOf())
: runtimeTypes.failure(stringInput, context);
}),
output => new Date(output).toISOString()
(m, c) => (isString(m) ? success(m) : failure(m, c)),
identity
either.chain(t.string.validate(input, context), (stringValue) => {
try {
JSON.parse(stringValue)
return t.success(stringValue)
} catch (error) {
return t.failure(stringValue, context, 'can not be parsed as JSON')
}
}),
String
return tryCatch(() => JSON.parse(s)).fold(() => t.failure(s, c), t.success)
}
either.chain(string.validate(u, c), s => {
const n = +s
return isNaN(n) || !Number.isInteger(n) ? failure(s, c) : success(n)
}),
String
(stringValue) =>
isValidAddress(stringValue)
? t.success(toChecksumAddress(stringValue))
: t.failure(stringValue, context, 'is not a valid address')
),
return new t.Type(name, is, (u, c) => (is(u) ? t.success(u) : t.failure(u, c)), t.identity)
}
baseType.validate(u, c).chain(val => {
const valid = validators.every(v => v(val))
return valid ? t.success(val) : t.failure(u, c, mkMessage(val))
}),
t.identity,
(stringValue) =>
isE164NumberStrict(stringValue)
? t.success(stringValue)
: t.failure(stringValue, context, 'is not a valid e164 number')
),
(m, c) => (isInteger(m) ? success(m) : failure(m, c)),
identity