Skip to content

Commit 4ccd75d

Browse files
committed
fix rounding for integer
1 parent 1fb3ba5 commit 4ccd75d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

spec/extra/errors/collect_all_errors.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"data": ["aa", "bb", "cc", "dd", "ee", "ff"],
7777
"valid": false,
7878
"error_entries": [
79-
{"schema_path": "/maxItems", "instance_path": "", "error": "expect array to have at most 5.0 items"}
79+
{"schema_path": "/maxItems", "instance_path": "", "error": "expect array to have at most 5 items"}
8080
]
8181
}
8282
]

src/resty/ljsonschema/init.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,12 +800,12 @@ generate_validator = function(ctx, schema)
800800
ctx:stmt(sformat( ' local itemcount = #%s', ctx:param(1)))
801801
if schema.minItems then
802802
ctx:stmt(sformat(' if itemcount < %d then', schema.minItems))
803-
ctx:handle_error(' ', sformat('"expect array to have at least %s items"', schema.minItems), '"/minItems"', '""')
803+
ctx:handle_error(' ', sformat('"expect array to have at least %s items"', math.floor(schema.minItems)), '"/minItems"', '""')
804804
ctx:stmt( ' end')
805805
end
806806
if schema.maxItems then
807807
ctx:stmt(sformat(' if itemcount > %d then', schema.maxItems))
808-
ctx:handle_error(' ', sformat('"expect array to have at most %s items"', schema.maxItems), '"/maxItems"', '""')
808+
ctx:handle_error(' ', sformat('"expect array to have at most %s items"', math.floor(schema.maxItems)), '"/maxItems"', '""')
809809
ctx:stmt( ' end')
810810
end
811811
end

0 commit comments

Comments
 (0)