fix:incorrect validMsg when required property doesn't assigned field of 'title' and 'titleEn' (#157)

This commit is contained in:
zhong-jie
2021-04-30 17:20:59 +08:00
committed by GitHub
parent 5e202ea610
commit 07cf89b6f3
6 changed files with 57 additions and 6 deletions

View File

@@ -19,7 +19,7 @@
<dependency>
<groupId>com.networknt</groupId>
<artifactId>json-schema-validator-i18n-support</artifactId>
<version>1.0.39_4</version>
<version>1.0.39_5</version>
</dependency>
<dependency>

View File

@@ -0,0 +1,51 @@
package we.util;
import org.junit.jupiter.api.Test;
import we.schema.util.I18nUtils;
import java.util.List;
import java.util.Locale;
import static org.junit.jupiter.api.Assertions.*;
class JsonSchemaUtilsTest {
@Test
void validateRequiredPropertyWithoutAssignedTitleAndTitleEn() {
I18nUtils.setContextLocale(new Locale("zh"));
try {
List<String> validateList = JsonSchemaUtils.validate(
"{\n" +
" \"properties\": {\n" +
" \"library\": {\n" +
" \"type\": \"object\",\n" +
" \"required\": [\n" +
" \"person\"\n" +
" ],\n" +
" \"properties\": {\n" +
" \"person\": {\n" +
" \"type\": \"string\"\n" +
" }\n" +
" }\n" +
" }\n" +
" },\n" +
" \"required\": [\n" +
" \"library\"\n" +
" ],\n" +
" \"type\": [\n" +
" \"object\",\n" +
" \"null\"\n" +
" ]\n" +
"}",
"{\n" +
" \"library\":{\n" +
" }\n" +
"}");
assertNotNull(validateList);
assertEquals(1, validateList.size());
assertEquals("person不能为空", validateList.get(0));
} finally {
I18nUtils.removeContextLocale();
}
}
}

View File

@@ -19,7 +19,7 @@
<dependency>
<groupId>com.networknt</groupId>
<artifactId>json-schema-validator-i18n-support</artifactId>
<version>1.0.39_4</version>
<version>1.0.39_5</version>
<scope>provided</scope>
</dependency>

View File

@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.networknt</groupId>
<artifactId>json-schema-validator-i18n-support</artifactId>
<version>1.0.39_4</version>
<version>1.0.39_5</version>
<description>POM was created from install:install-file</description>
<name>JsonSchemaValidator</name>
<properties>

View File

@@ -3,10 +3,10 @@
<groupId>com.networknt</groupId>
<artifactId>json-schema-validator-i18n-support</artifactId>
<versioning>
<release>1.0.39_4</release>
<release>1.0.39_5</release>
<versions>
<version>1.0.39_4</version>
<version>1.0.39_5</version>
</versions>
<lastUpdated>20210420061309</lastUpdated>
<lastUpdated>20210430081305</lastUpdated>
</versioning>
</metadata>