-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING: Remove ValidationBuilder.has (#163)
- Loading branch information
1 parent
52ed85e
commit d921b3a
Showing
3 changed files
with
6 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,26 +167,6 @@ class ValidationBuilderTest { | |
"poweruser@".let { assertEquals(1, countErrors(nullableRequiredValidation(it))) } | ||
} | ||
|
||
@Test | ||
fun alternativeSyntax() { | ||
val splitDoubleValidation = | ||
Validation<Register> { | ||
Register::password.has.minLength(1) | ||
Register::password.has.maxLength(10) | ||
Register::email.has.matches(".+@.+".toRegex()) | ||
} | ||
|
||
Register(email = "[email protected]", password = "a").let { assertEquals(Valid(it), splitDoubleValidation(it)) } | ||
Register( | ||
email = "[email protected]", | ||
password = "", | ||
).let { assertEquals(1, countErrors(splitDoubleValidation(it), Register::password)) } | ||
Register(email = "[email protected]", password = "aaaaaaaaaaa").let { | ||
assertEquals(1, countErrors(splitDoubleValidation(it), Register::password)) | ||
} | ||
Register(email = "tester@").let { assertEquals(2, countFieldsWithErrors(splitDoubleValidation(it))) } | ||
} | ||
|
||
@Test | ||
fun functionAccessorSyntax() { | ||
val splitDoubleValidation = | ||
|
@@ -479,7 +459,9 @@ class ValidationBuilderTest { | |
fun composeValidations() { | ||
val addressValidation = | ||
Validation<Address> { | ||
Address::address.has.minLength(1) | ||
Address::address { | ||
minLength(1) | ||
} | ||
} | ||
|
||
val validation = | ||
|
@@ -496,7 +478,9 @@ class ValidationBuilderTest { | |
fun replacePlaceholderInString() { | ||
val validation = | ||
Validation<Register> { | ||
Register::password.has.minLength(8) | ||
Register::password { | ||
minLength(8) | ||
} | ||
} | ||
assertTrue(validation(Register(password = ""))[Register::password]!![0].contains("8")) | ||
} | ||
|