Skip to content

Builtin Validations

mosop edited this page Dec 5, 2016 · 11 revisions

Inclusion

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

Element Inclusion

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

Minimum Length of Array

[WIP]

Required

[WIP]

Clone this wiki locally