Method: CDEKApiClient::Entities::Validatable::ClassMethods#validates

Defined in:
lib/cdek_api_client/entities/validatable.rb

#validates(attribute, options) ⇒ Object

Defines validations for attributes.

Parameters:

  • attribute (Symbol)

    the name of the attribute to validate.

  • options (Hash)

    the validation options.

Options Hash (options):

  • :type (Symbol)

    the expected type of the attribute.

  • :presence (Boolean)

    whether the attribute is required.



21
22
23
24
# File 'lib/cdek_api_client/entities/validatable.rb', line 21

def validates(attribute, options)
  @validations ||= {}
  @validations[attribute] = options
end