-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding default message for uri? predicate (#477)
* Adding default message for uri? predicate * Rubocop fixes
- Loading branch information
Showing
2 changed files
with
19 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,5 +107,7 @@ en: | |
|
||
uuid_v4?: "is not a valid UUID" | ||
|
||
uri?: "is not a valid URI" | ||
|
||
not: | ||
empty?: "cannot be empty" |
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,17 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe "Predicates: uri?" do | ||
subject(:schema) do | ||
Dry::Schema.Params do | ||
required(:uri) { str? & uri?(:https) } | ||
end | ||
end | ||
|
||
it "passes with valid input" do | ||
expect(schema.(uri: "https://www.example.com")).to be_success | ||
end | ||
|
||
it "fails with invalid input" do | ||
expect(schema.(uri: "not-a-uri").errors.to_h).to eql(uri: ["is not a valid URI"]) | ||
end | ||
end |