-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Aleksandr Dubinsky
committed
Feb 2, 2022
1 parent
33cd268
commit 11948a8
Showing
9 changed files
with
124 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 26 additions & 25 deletions
51
src/test/java/com/kjetland/jackson/jsonSchema/testData/ClassUsingValidation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,67 @@ | ||
package com.kjetland.jackson.jsonSchema.testData; | ||
|
||
import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaInject; | ||
import java.util.List; | ||
import java.util.Map; | ||
import javax.validation.constraints.*; | ||
import javax.validation.groups.Default; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.experimental.FieldDefaults; | ||
import lombok.extern.jackson.Jacksonized; | ||
|
||
public record ClassUsingValidation | ||
( | ||
@FieldDefaults(level = AccessLevel.PUBLIC, makeFinal = true) @Jacksonized @Builder @EqualsAndHashCode // Can be Java 17 record | ||
public class ClassUsingValidation | ||
{ | ||
@NotNull | ||
String stringUsingNotNull, | ||
String stringUsingNotNull; | ||
|
||
@NotBlank | ||
String stringUsingNotBlank, | ||
String stringUsingNotBlank; | ||
|
||
@NotNull | ||
@NotBlank | ||
String stringUsingNotBlankAndNotNull, | ||
String stringUsingNotBlankAndNotNull; | ||
|
||
@NotEmpty | ||
String stringUsingNotEmpty, | ||
String stringUsingNotEmpty; | ||
|
||
@NotEmpty | ||
List<String> notEmptyStringArray, // Per PojoArraysWithScala, we use always use Lists in Scala, and never raw arrays. | ||
List<String> notEmptyStringArray; // Per PojoArraysWithScala, we use always use Lists in Scala, and never raw arrays. | ||
|
||
@NotEmpty | ||
Map<String, String> notEmptyMap, | ||
Map<String, String> notEmptyMap; | ||
|
||
@Size(min=1, max=20) | ||
String stringUsingSize, | ||
String stringUsingSize; | ||
|
||
@Size(min=1) | ||
String stringUsingSizeOnlyMin, | ||
String stringUsingSizeOnlyMin; | ||
|
||
@Size(max=30) | ||
String stringUsingSizeOnlyMax, | ||
String stringUsingSizeOnlyMax; | ||
|
||
@Pattern(regexp = "_stringUsingPatternA|_stringUsingPatternB") | ||
String stringUsingPattern, | ||
String stringUsingPattern; | ||
|
||
@Pattern.List({ | ||
@Pattern(regexp = "^_stringUsing.*"), | ||
@Pattern(regexp = ".*PatternList$") | ||
}) | ||
String stringUsingPatternList, | ||
String stringUsingPatternList; | ||
|
||
@Min(1) | ||
int intMin, | ||
int intMin; | ||
@Max(10) | ||
int intMax, | ||
int intMax; | ||
@Min(1) | ||
double doubleMin, | ||
double doubleMin; | ||
@Max(10) | ||
double doubleMax, | ||
double doubleMax; | ||
@DecimalMin("1.5") | ||
double decimalMin, | ||
double decimalMin; | ||
@DecimalMax("2.5") | ||
double decimalMax, | ||
double decimalMax; | ||
|
||
String email | ||
) | ||
{ | ||
|
||
String email; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,25 +3,28 @@ | |
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaDefault; | ||
import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaExamples; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.experimental.FieldDefaults; | ||
import lombok.extern.jackson.Jacksonized; | ||
|
||
|
||
public record DefaultAndExamples | ||
( | ||
@FieldDefaults(level = AccessLevel.PUBLIC, makeFinal = true) @Jacksonized @Builder @EqualsAndHashCode // Can be Java 17 record | ||
public class DefaultAndExamples | ||
{ | ||
@JsonSchemaExamples({"[email protected]"}) | ||
String emailValue, | ||
String emailValue; | ||
|
||
@JsonSchemaDefault("12") | ||
@JsonSchemaExamples({"10", "14", "18"}) | ||
int fontSize, | ||
int fontSize; | ||
|
||
@JsonProperty(defaultValue = "ds") | ||
String defaultStringViaJsonValue, | ||
String defaultStringViaJsonValue; | ||
|
||
@JsonProperty(defaultValue = "1") | ||
int defaultIntViaJsonValue, | ||
int defaultIntViaJsonValue; | ||
|
||
@JsonProperty(defaultValue = "true") | ||
boolean defaultBoolViaJsonValue | ||
) | ||
{ | ||
boolean defaultBoolViaJsonValue; | ||
} |
Oops, something went wrong.