Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(m, c) => (isDate(m) ? success(m) : failure(m, c)),
identity
(m, c) => (isBase64Binary(m) ? success(m) : failure(m, c)),
identity
(m, c) => (isId(m) ? success(m) : failure(m, c)),
identity
(s, c) => {
if (s instanceof Set && arrayType.is(Array.from(s))) {
return t.success(s);
}
if (arrayType.is(s)) {
return t.success(new SerializableSet(Array.from(s)));
}
return t.failure(s, c);
},
t.identity
(input, context) =>
isMaybe(input) ? io.success(input) : io.failure(input, context),
io.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
(u, c) => (this.is(u) ? t.success(u) : t.failure(u, c)),
t.identity
t.string.validate(input, context).chain(keyPath => {
let res: t.Validation>
try {
res = t.success(CryptoKeyPath.fromString(keyPath))
} catch (e) {
res = t.failure(keyPath, context)
}
return res
}),
/** encode: converts a value of type Array to string */
(s, c) => {
if (s instanceof Set && arrayType.is(Array.from(s))) {
return t.success(s);
}
if (arrayType.is(s)) {
return t.success(new SerializableSet(Array.from(s)));
}
return t.failure(s, c);
},
t.identity
(u, c) => {
const validation = t.number.validate(u, c)
if (validation.isLeft()) {
return validation as any
} else {
const n = validation.value
const d = new Date(n)
return isNaN(d.getTime()) ? t.failure(n, c) : t.success(d)
}
},
a => a.getTime()