Skip to content

Commit

Permalink
Simplfiied validator, touch #567.
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulDalek committed Feb 10, 2025
1 parent bb15df7 commit eb2b507
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
20 changes: 1 addition & 19 deletions lib/envs.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,6 @@ const v = {
)
.transform((value) => (value !== '' ? value : undefined)),

// Checks if the string is a valid path directory (path format)
path: () =>
z
.string()
.trim()
.refine(
(value) => {
// Simplified regex to match both absolute and relative paths
return /^(\.\/|\.\.\/|\/|[a-zA-Z]:\\|[a-zA-Z]:\/)?((?:[\w-]+)[\\/]?)+$/.test(
value
);
},
{},
{
message: 'The string is an invalid path directory string.'
}
),

// Allows positive numbers or no value in which case the returned value will
// be undefined
positiveNum: () =>
Expand Down Expand Up @@ -115,7 +97,7 @@ const v = {

export const Config = z.object({
// puppeteer
PUPPETEER_TEMP_DIR: v.path(),
PUPPETEER_TEMP_DIR: v.string(),

// highcharts
HIGHCHARTS_VERSION: z
Expand Down
3 changes: 0 additions & 3 deletions tests/unit/envs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ describe('Environment variables should be correctly parsed', () => {
expect(Config.partial().parse(env).PUPPETEER_TEMP_DIR).toEqual(
'/another/path/to/dir'
);

env.PUPPETEER_TEMP_DIR = '';
expect(() => Config.partial().parse(env)).toThrow();
});

test('PUPPETEER_TEMP_DIR can be a relative path', () => {
Expand Down

0 comments on commit eb2b507

Please sign in to comment.