'if name == \'foo\' and value != \'bar\':
raise PluginError(\'foo must be bar\')
return value'

def validate_config_field(self, project, name, value, actor=None):

    for config in self.get_config(project=project, user=actor):
        if (config['name'] != name):
            continue
        if (value is None):
            if config.get('required'):
                raise PluginError('Field    is    required')
            if (config.get('type') == 'secret'):
                value = self.get_option(name, project)
            return value
        if isinstance(value, six.string_types):
            value = value.strip()
            if (not value):
                if config.get('required'):
                    raise PluginError('Field    is    required')
                if (config.get('type') == 'secret'):
                    value = self.get_option(name, project)
        for validator in DEFAULT_VALIDATORS.get(config['type'], ()):
            value = validator(project=project, value=value, actor=actor)
        for validator in config.get('validators', ()):
            value = validator(value, project=project, actor=actor)
        return value
    return value
