File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -4,8 +4,11 @@ import parseDuration from "parse-duration";
44const DurationString = z
55 . string ( )
66 . refine (
7- ( val ) => parseDuration ( val ) !== null ,
8- ( val ) => ( { message : `Invalid duration string: "${ val } "` } )
7+ ( val ) => {
8+ const ms = parseDuration ( val ) ;
9+ return ms !== null && ms > 0 ;
10+ } ,
11+ ( val ) => ( { message : `Invalid or non-positive duration string: "${ val } "` } )
912 ) ;
1013
1114const BracketSchema = z . object ( {
@@ -26,8 +29,8 @@ type ParsedBracket = {
2629
2730function requireParsedDuration ( input : string ) : number {
2831 const ms = parseDuration ( input ) ;
29- if ( ms === null ) {
30- throw new Error ( `Failed to parse duration string: "${ input } "` ) ;
32+ if ( ms === null || ms <= 0 ) {
33+ throw new Error ( `Duration must be strictly positive, got "${ input } " ( ${ ms } ms) ` ) ;
3134 }
3235 return ms ;
3336}
You can’t perform that action at this time.
0 commit comments