mirror of
https://github.com/Instadapp/boardroom-inc-protocol-Info.git
synced 2024-07-29 22:37:02 +00:00
31 lines
550 B
TypeScript
31 lines
550 B
TypeScript
import { validator } from "io-ts-validator";
|
|
import { ProtocolIo } from "../types";
|
|
import protocols from "../dist";
|
|
|
|
const errors = [];
|
|
|
|
for (const protocol of protocols) {
|
|
try {
|
|
validator(ProtocolIo).decodeSync(protocol);
|
|
} catch (e) {
|
|
errors.push({
|
|
protocol: protocol.name,
|
|
message: e,
|
|
});
|
|
}
|
|
}
|
|
|
|
const errorMessage = errors.reduce(
|
|
(message, error) =>
|
|
`
|
|
${message}\n
|
|
Error validating protocol: ${error.protocol}\n
|
|
${error.message}
|
|
`,
|
|
""
|
|
);
|
|
|
|
if (errorMessage) {
|
|
throw new Error(errorMessage);
|
|
}
|