-
Notifications
You must be signed in to change notification settings - Fork 6
Builtin Validations
mosop edited this page Dec 5, 2016
·
11 revisions
Tests if a parsed value is any of the specified values.
Can be applied to:
- String Option
- String Argument
class Trip < Optarg::Model
arg "somewhere_warm", any_of: %w(tahiti okinawa hawaii)
end
Trip.parse %w(gotland) # => raises an error
Tests if a parsed element value of array is any of the specified values.
Can be applied to:
- String Array Option
- String Array Argument
class EuropeanWallet < Optarg::Model
arg_array "bill", any_item_of: %w(€5 €10 €20 €50 €100 €200 €500)
end
EuropeanWallet.parse %w(€10 $50 €100) # => raises an error
Tests if the count of a parsed array is equal to or greater than the specified number.
class TeamOfCanoePolo < Optarg::Model
arg_array "member", min: 5
end
TeamOfCanoePolo.parse %w(freddie brian roger john) # => raises an error
[WIP]