format_attributes.lua
local jsonschema = require 'resty.ljsonschema'
local my_schema = {
type = 'object',
properties = {
foo = { type = 'string', format = 'date' },
bar = { type = 'string', format = 'date-time' },
baz = { type = 'string', format = 'time' },
},
}
local my_validator = jsonschema.generate_validator(my_schema)
local my_data = {
foo='2020-02-29',
bar='2020-02-29T08:30:00Z',
baz='08:30:60Z'
}
print(my_validator(my_data))
my_data = {
foo='20200-02-29', bar='2020-02-29T08:30:00Z',
baz='08:30:06.283185+00:20'
}
print(my_validator(my_data))