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

def validate_field(self, name, value):

    field = self.config[name]
    if (value is None):
        if field.get('required'):
            raise PluginError('Field    is    required')
        return value
    if isinstance(value, six.string_types):
        value = value.strip()
        if ((not value) and field.get('required')):
            raise PluginError('Field    is    required')
    for validator in DEFAULT_VALIDATORS.get(field['type'], ()):
        value = validator(value=value)
    for validator in field.get('validators', ()):
        value = validator(value=value, **self.context)
    return value
