@@ -21,55 +21,57 @@ export const flexibleBoolean = z.preprocess((val) => {
21
21
} , z . boolean ( ) ) ;
22
22
23
23
24
- export const numericStringSchemaNullable = z . coerce . string ( ) . or ( z . number ( ) ) . transform ( ( val , ctx ) => {
25
- const strValue = String ( val ) ;
26
- const trimmedStrValue = strValue . trim ( ) ;
24
+ export const numericStringSchemaNullable = z . coerce . string ( ) . nullable ( )
25
+ // export const numericStringSchemaNullable = z.coerce.string().or(z.number()).transform((val, ctx) => {
26
+ // const strValue = String(val);
27
+ // const trimmedStrValue = strValue.trim();
27
28
28
- if ( trimmedStrValue === '' ) {
29
- ctx . addIssue ( {
30
- code : z . ZodIssueCode . custom ,
31
- message : `Expected a numeric string or number, but received an empty string or string with only whitespace.` ,
32
- } ) ;
33
- return z . NEVER ;
34
- }
35
- if ( trimmedStrValue . toLowerCase ( ) === 'null' ) {
36
- return null ;
37
- }
38
- if ( isNaN ( Number ( trimmedStrValue ) ) ) {
39
- ctx . addIssue ( {
40
- code : z . ZodIssueCode . custom ,
41
- message : `Expected a numeric string or number, but received ${ trimmedStrValue } ` ,
42
- } ) ;
43
- return z . NEVER ;
44
- }
45
- return String ( trimmedStrValue ) ;
46
- } ) . nullable ( ) ;
29
+ // if (trimmedStrValue === '') {
30
+ // ctx.addIssue({
31
+ // code: z.ZodIssueCode.custom,
32
+ // message: `Expected a numeric string or number, but received an empty string or string with only whitespace.`,
33
+ // });
34
+ // return z.NEVER;
35
+ // }
36
+ // if (trimmedStrValue.toLowerCase() === 'null') {
37
+ // return null;
38
+ // }
39
+ // if (isNaN(Number(trimmedStrValue))) {
40
+ // ctx.addIssue({
41
+ // code: z.ZodIssueCode.custom,
42
+ // message: `Expected a numeric string or number, but received ${trimmedStrValue}`,
43
+ // });
44
+ // return z.NEVER;
45
+ // }
46
+ // return String(trimmedStrValue);
47
+ // }).nullable();
47
48
48
49
49
- export const numericStringSchema = z . coerce . string ( ) . transform ( ( val , ctx ) => {
50
- const strValue = String ( val ) ;
51
- const trimmedStrValue = strValue . trim ( ) ;
50
+ export const numericStringSchema = z . coerce . string ( )
51
+ // export const numericStringSchema = z.coerce.string().transform((val, ctx) => {
52
+ // const strValue = String(val);
53
+ // const trimmedStrValue = strValue.trim();
52
54
53
- if ( trimmedStrValue === '' ) {
54
- ctx . addIssue ( {
55
- code : z . ZodIssueCode . custom ,
56
- message : `Expected a numeric string or number, but received an empty string or string with only whitespace.` ,
57
- } ) ;
58
- return z . NEVER ;
59
- }
60
- if ( trimmedStrValue . toLowerCase ( ) === 'null' ) {
61
- ctx . addIssue ( {
62
- code : z . ZodIssueCode . custom ,
63
- message : `Expected a numeric string or number, but received an null as string` ,
64
- } ) ;
65
- return z . NEVER ;
66
- }
67
- if ( isNaN ( Number ( trimmedStrValue ) ) ) {
68
- ctx . addIssue ( {
69
- code : z . ZodIssueCode . custom ,
70
- message : `Expected a numeric string or number, but received ${ trimmedStrValue } ` ,
71
- } ) ;
72
- return z . NEVER ;
73
- }
74
- return String ( trimmedStrValue ) ;
75
- } ) ;
55
+ // if (trimmedStrValue === '') {
56
+ // ctx.addIssue({
57
+ // code: z.ZodIssueCode.custom,
58
+ // message: `Expected a numeric string or number, but received an empty string or string with only whitespace.`,
59
+ // });
60
+ // return z.NEVER;
61
+ // }
62
+ // if (trimmedStrValue.toLowerCase() === 'null') {
63
+ // ctx.addIssue({
64
+ // code: z.ZodIssueCode.custom,
65
+ // message: `Expected a numeric string or number, but received an null as string`,
66
+ // });
67
+ // return z.NEVER;
68
+ // }
69
+ // if (isNaN(Number(trimmedStrValue))) {
70
+ // ctx.addIssue({
71
+ // code: z.ZodIssueCode.custom,
72
+ // message: `Expected a numeric string or number, but received ${trimmedStrValue}`,
73
+ // });
74
+ // return z.NEVER;
75
+ // }
76
+ // return String(trimmedStrValue);
77
+ // });
0 commit comments