-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add regex pattern constraint (#4)
- Loading branch information
Showing
6 changed files
with
43 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,14 @@ defmodule AbsintheConstraints.ValidatorTest do | |
assert handle_constraint({:format, "email"}, "[email protected]") == [] | ||
end | ||
|
||
test "should validate regex pattern" do | ||
assert handle_constraint({:pattern, "^[A-Z]*$"}, "asdf") == [ | ||
"must match regular expression `^[A-Z]*$`" | ||
] | ||
|
||
assert handle_constraint({:pattern, "^[A-Z]*$"}, "ASDF") == [] | ||
end | ||
|
||
test "should validate min_items" do | ||
assert handle_constraint({:min_items, 5}, ["1", "2", "3", "4"]) == [ | ||
"must have at least 5 items" | ||
|
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