Skip to content

Commit

Permalink
Remove superflous members from ValidationResult
Browse files Browse the repository at this point in the history
  • Loading branch information
ahx committed May 30, 2024
1 parent 9b5d372 commit a3aed35
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 16 deletions.
6 changes: 1 addition & 5 deletions lib/openapi_first/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ def initialize(schema, openapi_version: '3.1', write: true, after_property_valid
end

def validate(data)
ValidationResult.new(
@schemer.validate(data),
schema:,
data:
)
ValidationResult.new(@schemer.validate(data))
end

private
Expand Down
6 changes: 1 addition & 5 deletions lib/openapi_first/schema/validation_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ module OpenapiFirst
class Schema
# Result of validating data against a schema. Return value of Schema#validate.
class ValidationResult
def initialize(validation, schema:, data:)
def initialize(validation)
@validation = validation
@schema = schema
@data = data
end

attr_reader :schema, :data

def error? = @validation.any?

# Returns an array of ValidationError objects.
Expand Down
6 changes: 0 additions & 6 deletions spec/schema_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,4 @@ def validate(data)
expect(error.details).to be_nil
end
end

describe 'validate.data' do
it 'returns the original data' do
expect(validate(data).data).to be data
end
end
end

0 comments on commit a3aed35

Please sign in to comment.