@@ -40,14 +40,29 @@ All the validators below accept the following options:
40
40
- ` allow_nil: true ` will permit ` nil ` (bypassing the validation)
41
41
- ` message: "..." ` customizes the error message when the validation fails
42
42
43
+ For example:
44
+
45
+ ``` ruby
46
+ field :comments , [Comment ], null: true ,
47
+ description: " Find comments by author ID or author name" do
48
+ argument :author_id , ID , required: false
49
+ argument :author_name , String , required: false
50
+ # Include a message for the end user if the validation fails:
51
+ validates required: {
52
+ one_of: [:author_id , :author_name ],
53
+ message: " May use either author_id or author_name, but not both."
54
+ }
55
+ end
56
+ ```
57
+
43
58
See each validator's API docs for details:
44
59
45
60
- ` length: { maximum: ..., minimum: ..., is: ..., within: ... } ` {{ "Schema::Validator::LengthValidator" | api_doc }}
46
61
- ` format: { with: /.../, without: /.../ } ` {{ "Schema::Validator::FormatValidator" | api_doc }}
47
62
- ` numericality: { greater_than:, greater_than_or_equal_to:, less_than:, less_than_or_equal_to:, other_than:, odd:, even: } ` {{ "Schema::Validator::NumericalityValidator" | api_doc }}
48
63
- ` inclusion: { in: [...] } ` {{ "Schema::Validator::InclusionValidator" | api_doc }}
49
64
- ` exclusion: { in: [...] } ` {{ "Schema::Validator::ExclusionValidator" | api_doc }}
50
- - ` required: { one_of: [...] } ` {{ "Schema::Validator::RequiredValidator" }}
65
+ - ` required: { one_of: [...] } ` {{ "Schema::Validator::RequiredValidator" | api_doc }}
51
66
52
67
53
68
Some of the validators accept customizable messages for certain validation failures; see the API docs for examples.
0 commit comments