Config parser to parse semicolon separated string key=value pairs as object
const objectSchema = z.object({ foo: z.string(), baz: z.string(), secret: z.string(),});// parses 'foo=bar;baz=qux;secret=secret' string to {foo: "bar", baz: "qux", secret: "secret"}const fooBarJsonParser = new SemicolonConfigParser({ validate: (value) => objectSchema.parse(value), protectedKeys: ['secret'], showProtectedKeys: 'prefix-suffix', // shows secret value with few characters from start and end on logging}); Copy
const objectSchema = z.object({ foo: z.string(), baz: z.string(), secret: z.string(),});// parses 'foo=bar;baz=qux;secret=secret' string to {foo: "bar", baz: "qux", secret: "secret"}const fooBarJsonParser = new SemicolonConfigParser({ validate: (value) => objectSchema.parse(value), protectedKeys: ['secret'], showProtectedKeys: 'prefix-suffix', // shows secret value with few characters from start and end on logging});
v1.0.0
the type of the output object
name of the parser
Config parser function
Error if parsing fails
Optional value validation after parsing
Error if validation fails
Optional build readable string from value for log (can hide sensitive part from logs) else toString is used
value to log
Build readable string from value
Optional
Config parser to parse semicolon separated string key=value pairs as object
Example
Implements
Since
v1.0.0