TODO: Consider adding the numerical validation options for Eno::List#items
       and possibly Eno::Section#fieldsets/elements/fields/lists as well.
342226
def list(name,
             loader = nil,
             enforce_element: @enforce_all_elements,
             enforce_values: true,
             exact_count: nil,
             max_count: nil,
             min_count: nil,
             required: nil,
             with_elements: false)

      enforce_element = required unless required.nil?
      enforce_element ||= exact_count && exact_count > 0 || min_count && min_count > 0
      loader = Proc.new if block_given?

      @touched = true

      unless @elements_associative.key?(name)
        if enforce_element
          raise Errors::Validation.missing_list(@context, name, @instruction)
        end

        return []
      end

      elements = @elements_associative[name]

      elements.each do |element|
        case element
        when List, Empty
          next
        when Field
          raise Errors::Validation.expected_list_got_field(@context, element.instruction)
        when Fieldset
          raise Errors::Validation.expected_list_got_fieldset(@context, element.instruction)
        when Section
          raise Errors::Validation.expected_list_got_section(@context, element.instruction)
        end
      end

      if elements.length > 1
        raise Errors::Validation.expected_list_got_lists(
          @context,
          name,
          elements.map(&:instruction)
        )
      end

      element = elements[0]
      element.touch

      count = element.is_a?(Empty) ? 0 : element.length

      if exact_count && count != exact_count
        raise Errors::Validation.exact_count_not_met(@context, element.instruction, exact_count)
      end

      if min_count && count < min_count
        raise Errors::Validation.min_count_not_met(@context, element.instruction, min_count)
      end

      if max_count && count > max_count
        raise Errors::Validation.max_count_not_met(@context, element.instruction, max_count)
      end

      if element.is_a?(Empty)
        []
      else
        element.items(loader, enforce_values: enforce_values, with_elements: with_elements)
      end
    end
139063
def field2length(self, field, **kwargs):
        
        attributes = {}

        validators = [
            validator
            for validator in field.validators
            if (
                hasattr(validator, "min")
                and hasattr(validator, "max")
                and hasattr(validator, "equal")
            )
        ]

        is_array = isinstance(
            field, (marshmallow.fields.Nested, marshmallow.fields.List)
        )
        min_attr = "minItems" if is_array else "minLength"
        max_attr = "maxItems" if is_array else "maxLength"

        for validator in validators:
            if validator.min is not None:
                if hasattr(attributes, min_attr):
                    attributes[min_attr] = max(attributes[min_attr], validator.min)
                else:
                    attributes[min_attr] = validator.min
            if validator.max is not None:
                if hasattr(attributes, max_attr):
                    attributes[max_attr] = min(attributes[max_attr], validator.max)
                else:
                    attributes[max_attr] = validator.max

        for validator in validators:
            if validator.equal is not None:
                attributes[min_attr] = validator.equal
                attributes[max_attr] = validator.equal
        return attributes
955830
def validate_options(options)
        options = options ? Hash[options] : {}
        options[:mailbox] ||= 'INBOX'
        options[:count]   ||= 10
        options[:order]   ||= :asc
        options[:what]    ||= :first
        options[:keys]    ||= 'ALL'
        options[:uid]     ||= nil
        options[:delete_after_find] ||= false
        options[:mailbox] = Net::IMAP.encode_utf7(options[:mailbox])
        options[:read_only] ||= false

        options
      end
265977
def validate_run_list(node, run_list, cookbooks, roles)
      run_list.split(",").each do |item|
        if item.start_with?("recipe[")
          # recipe[foo] or recipe[foo::bar]
          cb = item.split(/\[|\]/)[1].split(":")[0]
          unless cookbooks.member?(cb)
            STDERR.puts "ERROR: '#{node}' run list cookbook '#{cb}' is missing from the list of cookbooks in the manifest."
            exit(-1)
          end
        elsif item.start_with?("role[")
          # role[blah]
          role = item.split(/\[|\]/)[1]
          unless roles.member?(role)
            STDERR.puts "ERROR: '#{node}' run list role '#{role}' is missing from the list of roles in the manifest."
            exit(-1)
          end
        else
          STDERR.puts "ERROR: '#{node}' run list '#{item}' is an invalid run list entry in the manifest."
          exit(-1)
        end
      end
    end
771632
def _validate(self, val: list, log: Optional[Logger] = None) -> Tuple[bool, List[str]]:
        
        errors = []
        if not isinstance(val, list):
            errors.append(f"{self._variable_name}: {repr(val)} is not an array")
        else:
            for i in range(0, len(val)):
                v = val[i]
                if not conforms(v, self._type, self._context.NAMESPACE):
                    errors.append(f"{self._variable_name} element {i}: {v} is not a {self._type.__name__}")

            if len(val) < self._min:
                errors.append(
                    f"{self._variable_name}: at least {self._min} value{'s' if self._min > 1 else ''} required - "
                    f"element has {len(val) if len(val) else 'none'}")
            if self._max is not None and len(val) > self._max:
                errors.append(
                    f"{self._variable_name}: no more than {self._max} values permitted - element has {len(val)}")

        if log:
            for error in errors:
                log.log(error)
        return not bool(errors), errors
592268
def all_valid_with_nesting(self, formsets):
        ""
        if not all_valid(formsets):
            return False

        for formset in formsets:
            if not formset.is_bound:
                pass
            for form in formset:
                if hasattr(form, 'nested_formsets'):
                    if not self.all_valid_with_nesting(form.nested_formsets):
                        return False

                    #TODO - find out why this breaks when extra = 1 and just adding new item with no sub items
                    if (not hasattr(form, 'cleaned_data') or not form.cleaned_data) and self.formset_has_nested_data(form.nested_formsets):
                        form._errors["__all__"] = form.error_class(["Parent object must be created when creating nested inlines."])
                        return False
        return True
727505
def validate_min_itemsize(self, min_itemsize):
        
        if min_itemsize is None:
            return
        if not isinstance(min_itemsize, dict):
            return

        q = self.queryables()
        for k, v in min_itemsize.items():

            # ok, apply generally
            if k == 'values':
                continue
            if k not in q:
                raise ValueError(
                    "min_itemsize has the key [{key}] which is not an axis or "
                    "data_column".format(key=k))
799999
def item_params
      model = @item.class.name.split('::').last.underscore
      params.require(:"#{model}").permit!
    end
426898
function validateDoc (doc) {
  let issues = []

  function ignore (field) {
    return IGNORE_WARNINGS[field].indexOf(doc.name) !== -1
  }

  if (!doc.name) {
    issues.push('name missing in document')
  }

  if (!doc.description) {
    issues.push('function "' + doc.name + '": description missing')
  }

  if (!doc.syntax || doc.syntax.length === 0) {
    issues.push('function "' + doc.name + '": syntax missing')
  }

  if (!doc.examples || doc.examples.length === 0) {
    issues.push('function "' + doc.name + '": examples missing')
  }

  if (doc.parameters && doc.parameters.length) {
    doc.parameters.forEach(function (param, index) {
      if (!param.name || !param.name.trim()) {
        issues.push('function "' + doc.name + '": name missing of parameter ' + index + '')
      }
      if (!param.description || !param.description.trim()) {
        issues.push('function "' + doc.name + '": description missing for parameter ' + (param.name || index))
      }
      if (!param.types || !param.types.length) {
        issues.push('function "' + doc.name + '": types missing for parameter ' + (param.name || index))
      }
    })
  } else {
    if (!ignore('parameters')) {
      issues.push('function "' + doc.name + '": parameters missing')
    }
  }

  if (doc.returns) {
    if (!doc.returns.description || !doc.returns.description.trim()) {
      issues.push('function "' + doc.name + '": description missing of returns')
    }
    if (!doc.returns.types || !doc.returns.types.length) {
      issues.push('function "' + doc.name + '": types missing of returns')
    }
  } else {
    if (!ignore('returns')) {
      issues.push('function "' + doc.name + '": returns missing')
    }
  }

  if (!doc.seeAlso || doc.seeAlso.length === 0) {
    if (!ignore('seeAlso')) {
      issues.push('function "' + doc.name + '": seeAlso missing')
    }
  }

  return issues
}
1192326
def validate_items(self):
        
        logger.debug(fmt("Validating {}", self))
        from python_jsonschema_objects import classbuilder

        if self.__itemtype__ is None:
            return

        type_checks = self.__itemtype__
        if not isinstance(type_checks, (tuple, list)):
            # we were given items = {'type': 'blah'} ; thus ensure the type for all data.
            type_checks = [type_checks] * len(self.data)
        elif len(type_checks) > len(self.data):
            raise ValidationError(
                "{1} does not have sufficient elements to validate against {0}"
                .format(self.__itemtype__, self.data))

        typed_elems = []
        for elem, typ in zip(self.data, type_checks):
            if isinstance(typ, dict):
                for param, paramval in six.iteritems(typ):
                    validator = registry(param)
                    if validator is not None:
                        validator(paramval, elem, typ)
                typed_elems.append(elem)

            elif util.safe_issubclass(typ, classbuilder.LiteralValue):
                val = typ(elem)
                val.validate()
                typed_elems.append(val)
            elif util.safe_issubclass(typ, classbuilder.ProtocolBase):
                if not isinstance(elem, typ):
                    try:
                        if isinstance(elem, (six.string_types, six.integer_types, float)):
                            val = typ(elem)
                        else:
                            val = typ(**util.coerce_for_expansion(elem))
                    except TypeError as e:
                        raise ValidationError("'{0}' is not a valid value for '{1}': {2}"
                                              .format(elem, typ, e))
                else:
                    val = elem
                val.validate()
                typed_elems.append(val)

            elif util.safe_issubclass(typ, ArrayWrapper):
                val = typ(elem)
                val.validate()
                typed_elems.append(val)

            elif isinstance(typ, (classbuilder.TypeProxy, classbuilder.TypeRef)):
                try:
                    if isinstance(elem, (six.string_types, six.integer_types, float)):
                        val = typ(elem)
                    else:
                        val = typ(**util.coerce_for_expansion(elem))
                except TypeError as e:
                    raise ValidationError("'{0}' is not a valid value for '{1}': {2}"
                                          .format(elem, typ, e))
                else:
                    val.validate()
                    typed_elems.append(val)

        self._dirty = False
        self._typed = typed_elems
        return typed_elems
412290
def code(field, enum)
      code_field_name = :"#{field}_code"
      validates code_field_name, inclusion: enum.all.map { |item| item.code }
      instance_eval do
        define_method field do
          enum.select { |item| item.code==send(code_field_name.to_sym) }.first
        end
        define_method "#{field}=" do |value|
          send "#{code_field_name}=".to_sym, value.code
        end
      end
    end
733334
function findRequiredFields(formItems){
	let requiredFields = [];

	for (let i = 0; i < formItems.length; i++) {
		requiredFields.push({
			requiresValidation: formItems[i].props.isRequired,
			value: formItems[i], 
			regExp: formItems[i].props.regExp,
			fieldToBeValidated: formItems[i].props.fieldToBeValidated,
			validationFunction: formItems[i].props.validationFunction
		});
	}
	
	return requiredFields;
}
371228
def perform_validations(options={}) # :nodoc:
      if options.is_a?(Hash)
        options[:validate] == false || valid?(options[:context])
      else
        valid?
      end
    end
332956
def field_ok?(field)
      raise JSS::InvalidDataError, "Field elements must be hashes with :name, :type, and possibly :choices" unless field.kind_of? Hash
      raise JSS::InvalidDataError, "Fields require names" if field[:name].to_s.empty?
      raise JSS::InvalidDataError, "Fields :type must be one of: :#{FIELD_TYPES.join(', :')}" unless FIELD_TYPES.include? field[:type].to_sym

      if field[:type].to_sym == :menu
        unless field[:choices].kind_of? Array and  field[:choices].reject{|c| c.kind_of? String}.empty?
          raise JSS::InvalidDataError, "Choices for menu fields must be an Array of Strings"
        end # unless
      else
        field[:choices] = []
      end # if type -- menu
      true
    end
767113
def validate_field_list(fields, allow_fmt_specs=False, name_filter=None):
    
    formats = [i[4:] for i in globals() if i.startswith("fmt_")]

    try:
        fields = [i.strip() for i in fields.replace(',', ' ').split()]
    except AttributeError:
        # Not a string, expecting an iterable
        pass

    if name_filter:
        fields = [name_filter(name) for name in fields]

    for name in fields:
        if allow_fmt_specs and '.' in name:
            fullname = name
            name, fmtspecs = name.split('.', 1)
            for fmtspec in fmtspecs.split('.'):
                if fmtspec not in formats and fmtspec != "raw":
                    raise error.UserError("Unknown format specification %r in %r" % (fmtspec, fullname))

        if name not in engine.FieldDefinition.FIELDS and not engine.TorrentProxy.add_manifold_attribute(name):
            raise error.UserError("Unknown field name %r" % (name,))

    return fields
964887
def _validate(self, validator, data, key, position=None, includes=None):
        
        errors = []

        if position:
            position = '%s.%s' % (position, key)
        else:
            position = key

        try:  # Pull value out of data. Data can be a map or a list/sequence
            data_item = util.get_value(data, key)
        except KeyError:  # Oops, that field didn't exist.
            if validator.is_optional:  # Optional? Who cares.
                return errors
            # SHUT DOWN EVERTYHING
            errors.append('%s: Required field missing' % position)
            return errors

        return self._validate_item(validator, data_item, position, includes)
1092253
def _validate_item(self, item):
        """"""
        if not isinstance(item, six.string_types):
            raise ValidationError(
                self._record,
                "Text list field items must be strings, not '{}'".format(item.__class__)
            )

        words = item.split(' ')

        item_length_type = self._field.field_definition.get('itemLengthType')
        item_max_length = self._field.field_definition.get('itemMaxLength')
        item_min_length = self._field.field_definition.get('itemMinLength')
        if item_length_type is not None:
            # Min/max word count
            if item_length_type == 'words':
                if item_max_length is not None:
                    if len(words) > item_max_length:
                        raise ValidationError(
                            self._record,
                            "Field '{}' items cannot contain more than {} words".format(
                                self._field.name,
                                item_max_length
                            )
                        )
                if item_min_length is not None:
                    if len(words) < item_min_length:
                        raise ValidationError(
                            self._record,
                            "Field '{}' items must contain at least {} words".format(
                                self._field.name,
                                item_min_length
                            )
                        )

            # Min/max char count of full item
            else:
                if item_max_length is not None:
                    if len(item) > item_max_length:
                        raise ValidationError(
                            self._record,
                            "Field '{}' items cannot contain more than {} characters".format(
                                self._field.name,
                                item_max_length
                            )
                        )
                if item_min_length is not None:
                    if len(item) < item_min_length:
                        raise ValidationError(
                            self._record,
                            "Field '{}' items must contain at least {} characters".format(
                                self._field.name,
                                item_min_length
                            )
                        )