class Schemacop::BaseSchema

Attributes

root[R]

Public Instance Methods

invalid?(data) click to toggle source

Query data validity

@param data The data to validate. @return [Boolean] True if data is invalid, false otherwise.

# File lib/schemacop/base_schema.rb, line 17
def invalid?(data)
  !valid?(data)
end
valid?(data) click to toggle source

Query data validity

@param data The data to validate. @return [Boolean] True if the data is valid, false otherwise.

# File lib/schemacop/base_schema.rb, line 9
def valid?(data)
  validate(data).valid?
end
validate!(data) click to toggle source

Validate data for the defined Schema

@param data The data to validate. @raise [Schemacop::Exceptions::ValidationError] If the data is invalid,

this exception is thrown.

@return The processed data

# File lib/schemacop/base_schema.rb, line 27
def validate!(data)
  result = validate(data)

  unless result.valid?
    fail Exceptions::ValidationError, result.exception_message
  end

  return result.data
end