File tree Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Original file line number Diff line number Diff line change 1
1
import { z } from "zod" ;
2
- import { pino } from ' pino' ;
2
+ import { pino } from " pino" ;
3
3
const DEFAULT_NULL = process . env . DEFAULT_NULL === "true" ;
4
4
5
-
6
5
const logger = pino ( {
7
- level : process . env . LOG_LEVEL || ' info' ,
6
+ level : process . env . LOG_LEVEL || " info" ,
8
7
transport : {
9
- target : ' pino-pretty' ,
8
+ target : " pino-pretty" ,
10
9
options : {
11
10
colorize : true ,
12
11
levelFirst : true ,
@@ -15,11 +14,19 @@ const logger = pino({
15
14
} ,
16
15
} ) ;
17
16
18
- export const flexibleBoolean = z . preprocess ( ( val ) => {
19
- if ( typeof val === 'string' ) {
20
- return val . toLowerCase ( ) === 'true' ;
21
- }
17
+ export const flexibleBoolean = z . preprocess ( val => {
18
+ if ( typeof val === "boolean" ) {
22
19
return val ;
20
+ }
21
+ let result = "false" ;
22
+ try {
23
+ result = String ( val ) . toLowerCase ( ) ;
24
+ } catch {
25
+ return false ;
26
+ }
27
+ return result in [ "true" , "t" , "1" ] ;
23
28
} , z . boolean ( ) ) ;
24
29
25
- export const flexibleBooleanNullable = DEFAULT_NULL ? flexibleBoolean . nullable ( ) . default ( null ) : flexibleBoolean . nullable ( ) ;
30
+ export const flexibleBooleanNullable = DEFAULT_NULL
31
+ ? flexibleBoolean . nullable ( ) . default ( null )
32
+ : flexibleBoolean . nullable ( ) ;
You can’t perform that action at this time.
0 commit comments