@@ -30,9 +30,9 @@ import { getLogger } from "@std/log";
30
30
export class EnvNotSetError extends Error {
31
31
/**
32
32
* Create a new {@link EnvNotSetError}.
33
- *
33
+ *
34
34
* Use this when an environment variable is not set and the application tries to access it.
35
- *
35
+ *
36
36
* @param envVariable name of the environment variable
37
37
* @param cause the cause of the error, if any
38
38
*/
@@ -244,7 +244,7 @@ function logger() {
244
244
* A type that is compatible with Zod schemas.
245
245
*/
246
246
export type ZodSchemaCompat = {
247
- safeParse : ( value ?: string ) => { error : Error | null | undefined } ;
247
+ safeParse : ( value ?: string ) => { error ? : Error } ;
248
248
isOptional : ( ) => boolean ;
249
249
} ;
250
250
@@ -271,9 +271,9 @@ export const REQUIRED: ZodSchemaCompat = {
271
271
272
272
/**
273
273
* A `ZodSchemaCompat` validator that represents an optional variable.
274
- *
274
+ *
275
275
* Useful for projects where you don't need full-blown Zod schemas.
276
- *
276
+ *
277
277
* @example
278
278
* ```typescript
279
279
* import { initVariable, OPTIONAL } from "@wuespace/envar/";
@@ -292,9 +292,9 @@ export const OPTIONAL: ZodSchemaCompat = {
292
292
293
293
/**
294
294
* A `ZodSchemaCompat` validator that represents a required, non-empty variable.
295
- *
295
+ *
296
296
* Useful for projects where you don't need full-blown Zod schemas.
297
- *
297
+ *
298
298
* @example
299
299
* ```typescript
300
300
* import { initVariable, REQUIRED_NON_EMPTY } from "@wuespace/envar/";
@@ -307,16 +307,18 @@ export const REQUIRED_NON_EMPTY: ZodSchemaCompat = {
307
307
safeParse : ( val ) => ( {
308
308
error : typeof val === "string" && val . length > 0
309
309
? undefined
310
- : new Error ( `Expected value to be a non-empty string, but got "${ val ?. toString ( ) } "` ) ,
310
+ : new Error (
311
+ `Expected value to be a non-empty string, but got "${ val ?. toString ( ) } "` ,
312
+ ) ,
311
313
} ) ,
312
314
} ;
313
315
314
316
/**
315
317
* A `ZodSchemaCompat` validator that represents an optional, non-empty variable.
316
318
* Valid values are non-empty strings or undefined. Any other value is invalid.
317
- *
319
+ *
318
320
* Useful for projects where you don't need full-blown Zod schemas.
319
- *
321
+ *
320
322
* @example
321
323
* ```typescript
322
324
* import { initVariable, OPTIONAL_NON_EMPTY } from "@wuespace/envar/";
@@ -328,6 +330,8 @@ export const OPTIONAL_NON_EMPTY: ZodSchemaCompat = {
328
330
safeParse : ( val ) => ( {
329
331
error : typeof val === "string" && val . length > 0 || val === undefined
330
332
? undefined
331
- : new Error ( `Expected value to be a non-empty string or unset, but got "${ val ?. toString ( ) } "` ) ,
333
+ : new Error (
334
+ `Expected value to be a non-empty string or unset, but got "${ val ?. toString ( ) } "` ,
335
+ ) ,
332
336
} ) ,
333
337
} ;
0 commit comments