3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-14 22:05:01 +00:00

fix: broken config regex parsing

This commit is contained in:
Dragory 2023-04-02 03:18:55 +03:00
parent d231c72a5b
commit 9d4e9cf364
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
8 changed files with 29 additions and 54 deletions

View file

@ -1,5 +1,5 @@
import deepDiff from "deep-diff";
import { either, fold } from "fp-ts/lib/Either";
import { either, fold, isLeft } from "fp-ts/lib/Either";
import { pipe } from "fp-ts/lib/pipeable";
import * as t from "io-ts";
import { noop } from "./utils";
@ -106,6 +106,14 @@ export function validate(schema: t.Type<any>, value: any): StrictValidationError
);
}
export function parseIoTsSchema<T extends t.Type<any>>(schema: T, value: unknown): t.TypeOf<T> {
const decodeResult = schema.decode(value);
if (isLeft(decodeResult)) {
throw report(decodeResult);
}
return decodeResult.right;
}
/**
* Decodes and validates the given value against the given schema while also disallowing extra properties
* See: https://github.com/gcanti/io-ts/issues/322