Validates that the conditions Hash follows an expected format
346899
def conditions_hash_validations
      conditions.each do |comparator, mappings|
        errors.add(:conditions, "can't use undefined comparators") unless Scram::DSL::Definitions::COMPARATORS.keys.include? comparator.to_sym
        errors.add(:conditions, "comparators must have values of type Hash") unless mappings.is_a? Hash
      end
    end
19485
function normalizeCondition(condition) {
    if (!condition) throw new Error("Expected condition but got falsy value");
    if (typeof condition === "string") {
        return str => str.indexOf(condition) === 0;
    }
    if (typeof condition === "function") {
        return condition;
    }
    if (condition instanceof RegExp) {
        return condition.test.bind(condition);
    }
    if (Array.isArray(condition)) {
        const items = condition.map(c => normalizeCondition(c));
        return orMatcher(items);
    }
    if (typeof condition !== "object")
        throw Error(
            "Unexcepted " +
                typeof condition +
                " when condition was expected (" +
                condition +
                ")"
        );

    const matchers = [];
    Object.keys(condition).forEach(key => {
        const value = condition[key];
        switch (key) {
            case "or":
            case "include":
            case "test":
                if (value) matchers.push(RuleSet.normalizeCondition(value));
                break;
            case "and":
                if (value) {
                    const items = value.map(c => RuleSet.normalizeCondition(c));
                    matchers.push(andMatcher(items));
                }
                break;
            case "not":
            case "exclude":
                if (value) {
                    const matcher = RuleSet.normalizeCondition(value);
                    matchers.push(notMatcher(matcher));
                }
                break;
            default:
                throw new Error("Unexcepted property " + key + " in condition");
        }
    });
    if (matchers.length === 0)
        throw new Error("Excepted condition but got " + condition);
    if (matchers.length === 1) return matchers[0];
    return andMatcher(matchers);
}
1351197
def validate(*keys, &validator)
      key = flatten_keys(keys)
      values = validators[key] || []
      values << validator
      validators[key] = values
    end
365528
def assert_valid_conditions(conditions)
      case conditions
        when Hash
          conditions.each do |subject, bind_value|
            case subject
              when Symbol, String
                original = subject
                subject  = subject.to_s
                name     = subject[0, subject.index('.') || subject.length]

                unless @properties.named?(name) || @relationships.named?(name)
                  raise ArgumentError, "condition #{original.inspect} does not map to a property or relationship in #{model}"
                end
            end
          end

        when Array
          if conditions.empty?
            raise ArgumentError, '+options[:conditions]+ should not be empty'
          end

          first_condition = conditions.first

          unless first_condition.kind_of?(String) && !DataMapper::Ext.blank?(first_condition)
            raise ArgumentError, '+options[:conditions]+ should have a statement for the first entry'
          end
      end
    end
1197397
def validation_regex
      n = @kat.results[@page].size
      commands = "[#{ 'i' if hide_info? }#{ 'n' if next? }#{ 'p' if prev? }q]|"
      _01to09  = "[1-#{ [n, 9].min }]"
      _10to19  = "#{ "|1[0-#{ [n - 10, 9].min }]" if n >  9 }"
      _20to25  = "#{ "|2[0-#{ n - 20 }]" if n > 19 }"

      /^(#{ commands }#{ _01to09 }#{ _10to19 }#{ _20to25 })$/
    end
599004
def _validate_file_format(self, file_format):
        """"""

        if file_format not in self.valid_file_formats:
            raise InvalidFileFormatError(
                "{} is not a valid file format".format(file_format)
            )

        return file_format
789175
def check_proper_status(hsh)
      proper = hsh[:proper]
      proper_f = hsh[:proper_f]
      status = 'invalid'
      status = proper != proper_f ? 'formatted' : 'unchanged' if proper && proper_f
      hsh[:proper_status] = status if status.present?
      hsh
    end
456214
def standard?
      self.syntax = :invalid
      self.valid_size? or return false
      self.valid_encoding? or return false
      if self.local =~ STANDARD_LOCAL_REGEX
        self.syntax = :standard
        true
      else
        false
      end
    end
1257072
def ensureHashIndex(self, fields, unique = False, sparse = True, deduplicate = False) :
        """"""
        data = {
            "type" : "hash",
            "fields" : fields,
            "unique" : unique,
            "sparse" : sparse,
            "deduplicate": deduplicate
        }
        ind = Index(self, creationData = data)
        self.indexes["hash"][ind.infos["id"]] = ind
        return ind
881409
def validate(export_formats):
        
        for i in range(len(export_formats)):
            export_formats[i] = export_formats[i].strip().lower()
            if export_formats[i] not in [
                    ExportFormat.CHECKPOINT, ExportFormat.MODEL
            ]:
                raise TuneError("Unsupported export format: " +
                                export_formats[i])
1194202
def validate(self):
        
        val = self._condition.lower()
        if val and val[0] in "+-":
            val = val[1:]

        matcher = PatternFilter
        if not val or val.startswith('/') and val.endswith('/'):
            pass
        elif val.replace('.', '0').isdigit():
            matcher = FloatFilter
        elif self._condition in (TRUE | FALSE):
            matcher = BoolFilter
        elif any(val.endswith(i) for i in ByteSizeFilter.UNITS) and val[:-1].isdigit():
            matcher = ByteSizeFilter
        elif TimeFilter.TIMEDELTA_RE.match(val):
            matcher = TimeFilter

        self._inner = matcher(self._name, self._condition)
420951
def validate(result)
      if result.ntuples == 0
        raise NotFound
      elsif result.ntuples > 1
        raise TooManyChoices
      end
    end
592260
def _validate(self):
        
        if self.data_format is FormatType.PYTHON:
            self.data = self.raw_data
        elif self.data_format is FormatType.JSON:
            self._validate_json()
        elif self.data_format is FormatType.YAML:
            self._validate_yaml()
641844
def check_valid(var, key, expected):
    """

    att = getattr(var, key, None)
    if att is None:
        e = 'Variable does not have a `{}` attribute.'.format(key)
        warn(e)
    elif att != expected:
        e = 'Variable has a non-conforming {}. Got `{}`, expected `{}`'.format(key, att, expected)
        warn(e)
1173131
def conditions
      return ['1=0'] if !valid?

      if @val.blank?
        []
      else
        # FIXME: assume type is just string
        op  = '=?'
        val = @val
        if val =~ /\*$/
          op  = ' like ?'
          val = @val.gsub(/\*/, '%')
        end
        ["#{@col}#{op}", val]
      end
    end
934434
def valid_input?(input)
      case @attributes[:type]
      when :boolean
        [true,false].include?(input)
      when :enum
        raise MissingValuesError unless @attributes[:values]
        raise InvalidValuesError unless @attributes[:values].class == Array
        @attributes[:values].include?(input)
      when :string
        format = @attributes[:format] || :anything
        Validator.valid_input?(format, input)
      when :number
        [Integer, Fixnum].include?(input.class)
      when :timestamp
        # TODO timestamp pending
        # raise PendingBranchError
        true
      else
        false
      end
    end
1265478
def hash_to_condition(table, hash)
      conditions = hash.map do |attr, value|
        if value.is_a?(Array) && value.size > 1
          table[attr].in(value)
        elsif value.is_a?(Array)
          table[attr].eq(value[0])
        else
          table[attr].eq(value)
        end
      end

      conditions.reduce { |memo, cond| memo.and(cond) }
    end