Validates the formatting of a template field,
and checks for its name in the vars mapping table.
343830
function(field) {
    if (this._template) {
      var match = field.match(this.fieldRegex);
      return match && this.vars.hasOwnProperty(match[1]);
    }
    return false;
  }
1211140
private void validateField(FieldDefinition fieldDef) {
        Utils.require(!fieldDef.isXLinkField(), "Xlink fields are not allowed in Spider applications");
        
        // Validate scalar field analyzer.
        if (fieldDef.isScalarField()) {
            String analyzerName = fieldDef.getAnalyzerName();
            if (Utils.isEmpty(analyzerName)) {
                analyzerName = FieldType.getDefaultAnalyzer(fieldDef.getType());
                fieldDef.setAnalyzer(analyzerName);
            }
            FieldAnalyzer.verifyAnalyzer(fieldDef);
        }
    }
951161
private boolean validTemplateTypeExpression(Node expr) {
    // The expression must have at least three children the type keyword,
    // a type name (or type variable) and a type expression
    if (!checkParameterCount(expr, Keywords.TYPE)) {
      return false;
    }
    int paramCount = getCallParamCount(expr);
    // The first parameter must be a type variable or a type name
    Node firstParam = getCallArgument(expr, 0);
    if (!isTypeVar(firstParam) && !isTypeName(firstParam)) {
      warnInvalid("type name or type variable", expr);
      warnInvalidInside("template type operation", expr);
      return false;
    }
    // The rest of the parameters must be valid type expressions
    for (int i = 1; i < paramCount; i++) {
      if (!validTypeTransformationExpression(getCallArgument(expr, i))) {
        warnInvalidInside("template type operation", expr);
        return false;
      }
    }
    return true;
  }
603152
private void validateRecordedMapping() {
    if (currentMapping.destinationMutators == null || currentMapping.destinationMutators.isEmpty())
      errors.missingDestination();
    // If mapping a field without a source
    else if (options.skipType == 0
        && (currentMapping.sourceAccessors == null || currentMapping.sourceAccessors.isEmpty())
        && currentMapping.destinationMutators.get(currentMapping.destinationMutators.size() - 1)
            .getPropertyType()
            .equals(PropertyType.FIELD) && options.converter == null && !options.mapFromSource
        && sourceConstant == null)
      errors.missingSource();
    else if (options.skipType == 2 && options.condition != null)
      errors.conditionalSkipWithoutSource();
  }
475226
def validateField(cls, fieldName, value) :
        
        try :
            valValue = Collection.validateField(fieldName, value)
        except SchemaViolation as e:
            if fieldName == "_from" or fieldName == "_to" :
                return True
            else :
                raise e
        return valValue
1107190
def validate_variable_name(self, name):
        
        if not name:
            raise SerializerError("Variable name is empty".format(name))

        if name[0] not in PROPERTY_ALLOWED_START:
            msg = "Variable name '{}' must starts with a letter"
            raise SerializerError(msg.format(name))

        for item in name:
            if item not in PROPERTY_ALLOWED_CHARS:
                msg = ("Invalid variable name '{}': it must only contains "
                       "letters, numbers and '_' character")
                raise SerializerError(msg.format(name))

        return True
524622
def validate(self):
        
        from pyrocore.torrent import formatting

        super(PatternFilter, self).validate()
        self._value = self._value.lower()
        self._template = None
        self._is_regex = self._value.startswith('/') and self._value.endswith('/')
        if self._is_regex:
            self._matcher = re.compile(self._value[1:-1]).search
        elif self._value.startswith('{{') or self._value.endswith('}}'):
            def _template_globber(val, item):
                """Helper."""
                pattern = formatting.format_item(self._template, item).replace('[', '[[]')
                ##print('!!!', val, '~~~', pattern, '???')
                return fnmatch.fnmatchcase(val, pattern.lower())

            self._template = formatting.preparse(self._value)
            self._matcher = _template_globber
        else:
            self._matcher = lambda val, _: fnmatch.fnmatchcase(val, self._value)
947435
def validate_sort_fields(self):
        
        sort_fields = ','.join(self.options.sort_fields)
        if sort_fields == '*':
            sort_fields = self.get_output_fields()

        return formatting.validate_sort_fields(sort_fields or config.sort_fields)
116512
function validateString(context, name, def, map) {
  var value = context[name]

  if (value == null) {
    value = def
  }

  value = String(value)

  if (!(value in map)) {
    raise(value, 'options.' + name)
  }

  context[name] = value
}
631618
def _validate_templates(self, templates):
        
        if templates is None:
            return templates

        if not isinstance(templates, list):
            raise TypeError(logger.error("templates should be a list."))

        for template in templates:
            if not isinstance(template, dict):
                raise TypeError(logger.error("each item to be injected must be a dict."))

            if template.get('notifications'):
                for level, notification in six.iteritems(template.get('notifications')):
                    if level == 'errors':
                        logger.error(
                            "errors were returned during the injection process. errors: {0}".format(notification),
                            extra={"container": 'injector'}
                        )
                        raise Exception(notification)

            for key in ('user', 'name', 'group', 'chmod', 'config_path', 'path', 'checksum'):
                if key not in template:
                    raise KeyError(logger.error("The injector didn't return a {0}.".format(key)))

        return templates
245065
private void checkListMapType(Field field) {
        Class<?> cls = field.getType();
        boolean needCheckGenericType = false;
        if (List.class.isAssignableFrom(cls)) {
            // if check is list ignore check
            isList = true;
            needCheckGenericType = true;
        }
        if (Map.class.isAssignableFrom(cls)) {
            // if check is list ignore check
            isMap = true;
            needCheckGenericType = true;
        }

        if (!needCheckGenericType) {
            return;
        }

        Type type = field.getGenericType();
        if (type instanceof ParameterizedType) {
            ParameterizedType ptype = (ParameterizedType) type;

            Type[] actualTypeArguments = ptype.getActualTypeArguments();

            if (actualTypeArguments != null) {

                int length = actualTypeArguments.length;
                // validate
                if (isList) {
                    if (length != 1) {
                        throw new RuntimeException(
                                "List must use generic definiation like List<String>, please check  field name '"
                                        + field.getName() + " at class " + field.getDeclaringClass().getName());
                    }
                } else if (isMap) {
                    if (length != 2) {
                        throw new RuntimeException(
                                "Map must use generic definiation like Map<String, String>, please check  field name '"
                                        + field.getName() + " at class " + field.getDeclaringClass().getName());
                    }
                }

                Type targetType = actualTypeArguments[0];
                if (targetType instanceof Class) {
                    genericKeyType = (Class) targetType;
                }

                if (actualTypeArguments.length > 1) {
                    targetType = actualTypeArguments[1];
                    if (targetType instanceof Class) {
                        genericeValueType = (Class) targetType;
                    }
                }

            }
        }

    }
1181550
private boolean isValidTemplateElement(String template, String element) {

        List elements = new ArrayList(getTemplateElements(template));
        Iterator i = elements.iterator();
        while (i.hasNext()) {
            CmsDialogElement currElement = (CmsDialogElement)i.next();
            if (element.equals(currElement.getName())) {
                return true;
            }
        }

        return false;
    }
1038023
def validate_field(field, allowed_keys, allowed_types):
    """"""
    for key, value in field.items():
        if key not in allowed_keys:
            raise exceptions.ParametersFieldError(key, "property")
        if key == defs.TYPE:
            if value not in allowed_types:
                raise exceptions.ParametersFieldError(value, key)
        if key == defs.VALUE:
            if not is_valid_field_name(value):
                raise exceptions.ParametersFieldError(value, "field name")
740323
def validate_attr(self, append):
        """"""
        if append:
            existing_fields = getattr(self.attrs, self.kind_attr, None)
            if (existing_fields is not None and
                    existing_fields != list(self.values)):
                raise ValueError("appended items do not match existing items"
                                 " in table!")

            existing_dtype = getattr(self.attrs, self.dtype_attr, None)
            if (existing_dtype is not None and
                    existing_dtype != self.dtype):
                raise ValueError("appended items dtype do not match existing "
                                 "items dtype in table!")
1230815
private boolean isCsvField(final String field, final ValidationContext<Object> validationContext) {
        return validationContext.getBeanMapping().getColumnMapping(field).isPresent();
    }
245208
def validate_template(template_body=None, template_url=None, region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    try:
        # Returns an object if json is validated and an exception if its not
        return conn.validate_template(template_body, template_url)
    except BotoServerError as e:
        log.debug(e)
        msg = 'Error while trying to validate template {0}.'.format(template_body)
        log.error(msg)
        return six.text_type(e)
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)