Skip to content

Commit

Permalink
Fix lint error
Browse files Browse the repository at this point in the history
Some cleanup
  • Loading branch information
Blacksmoke16 committed Feb 26, 2022
1 parent 9404cfa commit 899ddd1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ struct AtLeastOneOfValidatorTest < AVD::Spec::ConstraintValidatorTestCase

message = [constraint.message]

constraints.each_with_index do |constraint, idx|
message << " [#{idx + 1}] #{self.expect_violation_at(idx, value, constraint).first.message}"
constraints.each_with_index do |c, idx|
message << " [#{idx + 1}] #{self.expect_violation_at(idx, value, c).first.message}"
end

self.validator.validate value, constraint
Expand Down
11 changes: 5 additions & 6 deletions src/components/validator/src/spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ module Athena::Validator::Spec
include Athena::Validator::Validator::ValidatorInterface

setter violations_callback : Proc(AVD::Violation::ConstraintViolationListInterface)
@violations : AVD::Violation::ConstraintViolationListInterface = AVD::Violation::ConstraintViolationList.new

def self.new(violations : AVD::Violation::ConstraintViolationListInterface = AVD::Violation::ConstraintViolationList.new)
new ->{ violations }
Expand All @@ -152,27 +151,27 @@ module Athena::Validator::Spec

# :inherit:
def validate(value : _, constraints : Array(AVD::Constraint) | AVD::Constraint | Nil = nil, groups : Array(String) | String | AVD::Constraints::GroupSequence | Nil = nil) : AVD::Violation::ConstraintViolationListInterface
@violations = @violations_callback.call
@violations_callback.call
end

# :inherit:
def validate_property(object : AVD::Validatable, property_name : String, groups : Array(String) | String | AVD::Constraints::GroupSequence | Nil = nil) : AVD::Violation::ConstraintViolationListInterface
@violations = @violations_callback.call
@violations_callback.call
end

# :inherit:
def validate_property_value(object : AVD::Validatable, property_name : String, value : _, groups : Array(String) | String | AVD::Constraints::GroupSequence | Nil = nil) : AVD::Violation::ConstraintViolationListInterface
@violations = @violations_callback.call
@violations_callback.call
end

# :inherit:
def start_context(root = nil) : AVD::Validator::ContextualValidatorInterface
MockContextualValidator.new @violations
MockContextualValidator.new @violations_callback.call
end

# :inherit:
def in_context(context : AVD::ExecutionContextInterface) : AVD::Validator::ContextualValidatorInterface
MockContextualValidator.new @violations
MockContextualValidator.new @violations_callback.call
end
end

Expand Down

0 comments on commit 899ddd1

Please sign in to comment.