-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
date and date-time #979
Comments
version 1.3.3 |
Your schema is not valid and there is insufficient information to reproduce. As you are using the |
This is a jsonschema file downloaded from Amazon. I can't change its format. I'll try another version or look at the source code. |
After testing, I found that version 1.1.0 does not have this problem with time verification. |
Closing as this cannot be reproduced. package com.networknt.schema;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import com.networknt.schema.SpecVersion.VersionFlag;
public class Issue969Test {
@Test
void test() {
SchemaValidatorsConfig config = new SchemaValidatorsConfig();
config.setFormatAssertionsEnabled(true);
String schemaData = "{\r\n"
+ " \"oneOf\": [\r\n"
+ " {\r\n"
+ " \"format\": \"date\"\r\n"
+ " },\r\n"
+ " {\r\n"
+ " \"format\": \"date-time\"\r\n"
+ " }\r\n"
+ " ]\r\n"
+ "}";
JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData, config);
assertTrue(schema.validate("\"2024-02-23\"", InputFormat.JSON).isEmpty());
assertFalse(schema.validate("\"2024-02-30\"", InputFormat.JSON).isEmpty());
assertTrue(schema.validate("\"2021-12-31T23:59:59Z\"", InputFormat.JSON).isEmpty());
assertFalse(schema.validate("\"2021-12-31T23:59:59\"", InputFormat.JSON).isEmpty());
}
} |
example:
my jsonschema:
"restock_date" : {
"title" : "Restock Date",
"description" : "Date that product will be restocked",
"editable" : true,
"hidden" : false,
"examples" : [ "2020-05-05" ],
"type" : "string",
"oneOf" : [ {
"type" : "string",
"format" : "date"
}, {
"type" : "string",
"format" : "date-time"
} ]
}
Data that needs to be verified:
"restock_date" : "2024-02-23"
===============================
This verification will report an error with error code 1022. It should satisfy all the conditions in oneOf at the same time
The text was updated successfully, but these errors were encountered: