mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 04:25:01 +00:00
feat: limit logs timestamp_format length
This commit is contained in:
parent
c82e147ea1
commit
fafaefa1fb
3 changed files with 23 additions and 4 deletions
17
backend/src/utils/iotsUtils.ts
Normal file
17
backend/src/utils/iotsUtils.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import * as t from "io-ts";
|
||||
|
||||
interface BoundedStringBrand {
|
||||
readonly BoundedString: unique symbol;
|
||||
}
|
||||
|
||||
export function asBoundedString(str: string) {
|
||||
return str as t.Branded<string, BoundedStringBrand>;
|
||||
}
|
||||
|
||||
export function tBoundedString(min: number, max: number) {
|
||||
return t.brand(
|
||||
t.string,
|
||||
(str): str is t.Branded<string, BoundedStringBrand> => (str.length >= min && str.length <= max),
|
||||
"BoundedString",
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue