lib/apia/definitions/error.rb
# Validate that this error class is valid and thus can be used in the
# API.
#
# @param errors [Apia::ManifestErrors]
# @reeturn [void]
Validate that this error class is valid and thus can be used in the
API.
Validate that this error class is valid and thus can be used in the API .
def validate(errors)
        unless code.is_a?(Symbol)
          errors.add self, 'InvalidCode', 'Code must be a symbol'
        end
        if http_status_code.is_a?(Integer) && ::Rack::Utils::HTTP_STATUS_CODES[http_status_code]
        elsif http_status_code.is_a?(Integer)
          errors.add self, 'InvalidHTTPStatus', "The HTTP status is not valid (must be one of #{::Rack::Utils::HTTP_STATUS_CODES.keys.join(', ')})"
        else
          errors.add self, 'InvalidHTTPStatus', 'The HTTP status is not valid (must be an integer)'
        end
        @fields.validate(errors, self)
      end
def validate ( errors ) unless code . is_a? ( Symbol ) errors . add self , 'InvalidCode' , 'Code must be a symbol' end if http_status_code . is_a? ( Integer ) && :: Rack :: Utils :: HTTP_STATUS_CODES [ http_status_code ] elsif http_status_code . is_a? ( Integer ) errors . add self , 'InvalidHTTPStatus' , "The HTTP status is not valid (must be one of #{::Rack::Utils::HTTP_STATUS_CODES.keys.join(', ')})" else errors . add self , 'InvalidHTTPStatus' , 'The HTTP status is not valid (must be an integer)' end @fields . validate ( errors , self ) end
Validate that this error class is valid and thus can be used in the
API.
Validate that this error class is valid and thus can be used in the API .
# OK
errors
<not_specific>
<not_specific>
None
reeturn
None