kit-contract edge
Array
class
Kit::Contract::BuiltInContracts::Array
View Source
Kit::Contract::BuiltInContracts::Array
Enable Contracts on Array instances, and on elements at specific indeces.
Supported contract types:
of
: alias ofevery_value
, for typeswith
: run on the value of specific indeces (this is the default when using Hash[data])at
: here ordering mattersevery
: run on every valueinstance
: run on the hash instance itselfsize
: instance contract about size
Supported internal types of behaviour:
every_value
: run on every valueindex
: run on value at index Ninstance
: run on the hash instance itself
Todo: add exemples.
Link to this section Summary ⚠️ Private APIs are currently hidden.
Inherited from InstantiableContract
Inherited from InstantiableContract
Link to this section Class methods 8
Convenience methods. They provide a slighly terser external API to instantiate contracts.
Link to this section Instance methods 10
contract Hash.of(And[Integer, Gt[0]] => Contract)
contract Array.of(Contract).size(1)
contract Or[Contract, Array.of(Contract)]
contract Array.of(Contract).size(1)
contract And[Integer, ->(x) { x > 0 }]
NOTE: this will only be useful when Organizer can handle any signature
Position matters on this one contract Array.of(Contract)