class Validate::AST::Rules::Unanimous

Public Class Methods

new(constraints) click to toggle source
# File lib/validate/ast.rb, line 266
def initialize(constraints)
  @constraints = constraints.freeze
end

Public Instance Methods

inspect() click to toggle source
# File lib/validate/ast.rb, line 281
def inspect
  return @constraints.first.inspect if @constraints.one?

  "(#{@constraints.map(&:inspect).join(' & ')})"
end
message() click to toggle source
# File lib/validate/ast.rb, line 287
def message
  'both ' + @constraints
            .size
            .times
            .map { |i| "[#{constraint_message(i)}]" }
            .join(', and ')
end
name() click to toggle source
# File lib/validate/ast.rb, line 277
def name
  'both_' + @constraints.map(&:name).sort.join('_and_')
end
valid?(value, _ = Constraints::ValidationContext.none) click to toggle source
# File lib/validate/ast.rb, line 270
def valid?(value, _ = Constraints::ValidationContext.none)
  ctx = Constraints::ValidationContext.root(value)
  @constraints.all? do |c|
    c.valid?(value, ctx) && !ctx.has_violations?
  end
end