kit-contract edge
Hash
class
Kit::Contract::BuiltInContracts::Hash
View Source
Kit::Contract::BuiltInContracts::Hash
Enable Contracts on Hash instances, on keys themselves, on values themselves, and on elements at specific keys.
Supported contract types:
of: combo ofevery_keyandevery_valueas a Hash, more readable for typeswith: run on the value of specific keys (this is the default when using Hash[data])every: run on every [key, value] pairevery_key: run on every keyevery_value: run on every valueinstance: run on the hash instance itselfsize: instance contract about size
Supported internal types of behaviour:
every_key: run on every keyevery_key_value: run on every [key, value]every_value: run on every valuekeyword_args: run on the value of specific keysinstance: 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 9
Convenience methods. They provide a slighly terser external API to instantiate contracts.
Link to this section Instance methods 12
contract Or[Contract, Array.of(Contract)]
contract Or[Contract, Array.of(Contract)]
contract Or[Contract, Array.of(Contract)]
contract Or[Contract, Array.of(Contract)]
contract Hash.of(Type1 => Type2).size(1)
contract And[Integer, ->(x) { x > 0 }]
NOTE: this will only be useful when Organizer can handle any signature
before Ct::Args[Ct::Hash.of(Ct::NonNil => Ct::Contract)] Add contracts on specific keys.
before Ct::Args[Ct::Array.of(Ct::NonNil)] Add keys that must not exist on the hash.