-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust oneofstrings validator to improve formatting
- Loading branch information
1 parent
4f514e9
commit 302f7fb
Showing
9 changed files
with
31 additions
and
8 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
19 changes: 19 additions & 0 deletions
19
acme-lib/acme-lib-validation/src/test/kotlin/com/acme/validation/OneOfStringsTest.kt
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,19 @@ | ||
package com.acme.validation | ||
|
||
import io.kotest.core.spec.style.ShouldSpec | ||
import io.kotest.matchers.collections.shouldHaveSize | ||
import jakarta.validation.Validation | ||
import jakarta.validation.ValidatorFactory | ||
|
||
class OneOfStringsTest: ShouldSpec({ | ||
data class FakeBean( | ||
@field:OneOfStrings(values = "Doctor, Nurse, Pediatrician") | ||
val title: String? | ||
) | ||
|
||
should("result in errors for invalid value") { | ||
val validator = Validation.buildDefaultValidatorFactory().validator | ||
val results = validator.validate(FakeBean("Doc")) | ||
results shouldHaveSize 1 | ||
} | ||
}) |
2 changes: 2 additions & 0 deletions
2
acme-lib/acme-lib-validation/src/test/resources/ValidationMessages.properties
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,2 @@ | ||
com.acme.validation.PhoneNumber.message=invalid phone number | ||
com.acme.validation.OneOfStrings.message=must be one of: {values} |
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