-
-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add string not matching pattern field assertion
- Loading branch information
Showing
15 changed files
with
150 additions
and
123 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
5 changes: 4 additions & 1 deletion
5
src/main/java/tech/jhipster/lite/module/domain/JHipsterSlug.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
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
5 changes: 4 additions & 1 deletion
5
src/main/java/tech/jhipster/lite/module/domain/resource/JHipsterModuleTag.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
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
63 changes: 63 additions & 0 deletions
63
...main/java/tech/jhipster/lite/shared/error/domain/NotMatchingExpectedPatternException.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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package tech.jhipster.lite.shared.error.domain; | ||
|
||
import java.util.Map; | ||
import java.util.regex.Pattern; | ||
|
||
public final class NotMatchingExpectedPatternException extends AssertionException { | ||
|
||
private final String pattern; | ||
|
||
private NotMatchingExpectedPatternException(NotMatchingExpectedPatternExceptionBuilder builder) { | ||
super(builder.field, builder.message()); | ||
pattern = builder.pattern; | ||
} | ||
|
||
public static NotMatchingExpectedPatternExceptionBuilder builder() { | ||
return new NotMatchingExpectedPatternExceptionBuilder(); | ||
} | ||
|
||
public static final class NotMatchingExpectedPatternExceptionBuilder { | ||
|
||
private String value; | ||
private String pattern; | ||
private String field; | ||
|
||
private NotMatchingExpectedPatternExceptionBuilder() {} | ||
|
||
NotMatchingExpectedPatternExceptionBuilder field(String field) { | ||
this.field = field; | ||
|
||
return this; | ||
} | ||
|
||
NotMatchingExpectedPatternExceptionBuilder value(String value) { | ||
this.value = value; | ||
|
||
return this; | ||
} | ||
|
||
NotMatchingExpectedPatternExceptionBuilder pattern(Pattern pattern) { | ||
this.pattern = pattern.pattern(); | ||
|
||
return this; | ||
} | ||
|
||
private String message() { | ||
return "The value \"" + value + "\" in field \"" + field + "\" must match the pattern " + pattern; | ||
} | ||
|
||
public NotMatchingExpectedPatternException build() { | ||
return new NotMatchingExpectedPatternException(this); | ||
} | ||
} | ||
|
||
@Override | ||
public AssertionErrorType type() { | ||
return AssertionErrorType.STRING_NOT_MATCHING_PATTERN; | ||
} | ||
|
||
@Override | ||
public Map<String, String> parameters() { | ||
return Map.of("pattern", pattern); | ||
} | ||
} |
17 changes: 0 additions & 17 deletions
17
src/main/java/tech/jhipster/lite/shared/error/domain/UrlSafeSingleWordException.java
This file was deleted.
Oops, something went wrong.
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
20 changes: 0 additions & 20 deletions
20
src/test/java/tech/jhipster/lite/module/domain/JHipsterTagsTest.java
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.