-
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.
* wip * map valid * map and docs * version * classifier update * more docs * added other example
- Loading branch information
1 parent
d325a27
commit 6c9d48b
Showing
8 changed files
with
88 additions
and
27 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
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from copy import copy | ||
|
||
from koda_validate import Invalid, StringValidator, TypeErr, Valid | ||
|
||
|
||
def test_valid_map() -> None: | ||
assert Valid("something").map(lambda x: x.replace("some", "no")) == Valid("nothing") | ||
assert Valid(5).map(str) == Valid("5") | ||
|
||
inv = Invalid( | ||
err_type=TypeErr(str), | ||
value=5, | ||
validator=StringValidator(), | ||
) | ||
|
||
mapped = copy(inv).map(lambda x: x.replace("some", "no")) | ||
assert isinstance(mapped, Invalid) | ||
assert mapped.value == inv.value | ||
assert mapped.err_type == inv.err_type | ||
assert mapped.validator == inv.validator |