Skip to content

Commit 1722950

Browse files
committed
Indexable datetime checks absolute value - catch for bad data
1 parent 2fede44 commit 1722950

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

schemas-analyze/src/main/java/org/cedar/schemas/analyze/Temporal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static boolean indexable(Long year) {
127127
// this number is a bit arbitrary, and prone to change when ES switches to the Java time library (minimum supported year
128128
// being -999,999,999). We will limit the year ourselves instead to -100,000,000 -- since this is a fairly safe bet for
129129
// supportability across many date libraries if the utcDateTime ends up used as is by a downstream app.
130-
return year >= -100_000_000L;
130+
return Math.abs(year) <= 100_000_000L;
131131
}
132132

133133
static String precision(TemporalAccessor date) {

schemas-analyze/src/test/groovy/org/cedar/schemas/analyze/DateInfoSpec.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class DateInfoSpec extends Specification {
7171
'-3000' | false || ValidDescriptor.VALID | 'Years' | true | null | '-3000-12-31T23:59:59.999Z'
7272
'-100000001' | true || ValidDescriptor.VALID | 'Years' | false | null | '-100000001-01-01T00:00:00Z'
7373
'-100000002' | false || ValidDescriptor.VALID | 'Years' | false | null | '-100000002-12-31T23:59:59.999Z'
74+
'100000002' | false || ValidDescriptor.VALID | 'Years' | false | null | '100000002-12-31T23:59:59.999Z'
7475
'ABC' | true || ValidDescriptor.INVALID | null | false | null | null
7576
'' | true || ValidDescriptor.UNDEFINED | null | true | null | null
7677
null | true || ValidDescriptor.UNDEFINED | null | true | null | null

0 commit comments

Comments
 (0)