File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,16 @@ const rfc3339 = [
5858 } ,
5959] ;
6060
61+ function matchFilter ( matches : RegExpMatchArray | null ) : boolean {
62+ if ( ! matches ) {
63+ return false ;
64+ }
65+
66+ const truthyMatches = matches . filter ( ( match ) => ! ! match ) ;
67+
68+ return truthyMatches . length > 2 ;
69+ }
70+
6171function inferRFC3339 ( value : string ) : JSONDateTimeFormat | undefined {
6272 const rfc3339Matches = rfc3339
6373 . map ( ( rfc ) => {
@@ -67,7 +77,7 @@ function inferRFC3339(value: string): JSONDateTimeFormat | undefined {
6777 extensions : rfc . extensions ,
6878 } ;
6979 } )
70- . filter ( ( rfc ) => rfc . matches !== null && rfc . matches . some ( ( i ) => i ) ) ;
80+ . filter ( ( rfc ) => matchFilter ( rfc . matches ) ) ;
7181
7282 const rfc3339BestMatch = rfc3339Matches . sort (
7383 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Original file line number Diff line number Diff line change @@ -811,3 +811,12 @@ describe("credit cards", () => {
811811 } ,
812812 ) ;
813813} ) ;
814+
815+ describe ( "without format" , ( ) => {
816+ test . each ( [ "46" ] ) ( "%p should be inferred as having no format" , ( value ) => {
817+ expect ( inferType ( value ) ) . toEqual ( {
818+ name : "string" ,
819+ value,
820+ } ) ;
821+ } ) ;
822+ } ) ;
You can’t perform that action at this time.
0 commit comments