class Result

The result of parsing and validating content parameters.

Definitions

def initialize(value, errors)

Initialize the result.

Signature

parameter value Hash

The converted and filtered value.

parameter errors Array(Error)

The validation errors.

Implementation

def initialize(value, errors)
	@value = value
	@errors = errors.freeze
end

attr :value

The converted and filtered value.

attr :errors

The validation errors.

def [](key)

Fetch an entry from the result value.

Signature

parameter key Object

The value key.

returns Object | Nil

The corresponding value.

Implementation

def [](key)
	return @value[key]
end

def dig(*path)

Fetch an entry nested within the result value.

Signature

parameter path Array(Object)

The nested value path.

returns Object | Nil

The corresponding value.

Implementation

def dig(*path)
	return @value.dig(*path)
end

def valid?

Whether the parameters are valid.

Signature

returns Boolean

True when there are no validation errors.

Implementation

def valid?
	return @errors.empty?
end