S009

SchemasStandard

check for Schema of TypeList or TypeSet with ValidateFunc or ValidateDiagFunc configured

The S009 analyzer reports cases of TypeList or TypeSet schemas configuring ValidateFunc or ValidateDiagFunc, which will fail schema validation.

Neither validator is supported at the top level of a list or set. Validation belongs on the element schema instead, where it runs against each element.

Examples

&schema.Schema{
    Type:         schema.TypeList,
    Elem:         &schema.Schema{Type: schema.TypeString},
    ValidateFunc: /* ... */,
}

&schema.Schema{
    Type:             schema.TypeSet,
    Elem:             &schema.Schema{Type: schema.TypeString},
    ValidateDiagFunc: /* ... */,
}
&schema.Schema{
    Type: schema.TypeList,
    Elem: &schema.Schema{Type: schema.TypeString},
}

&schema.Schema{
    Type: schema.TypeSet,
    Elem: &schema.Schema{Type: schema.TypeString},
}

&schema.Schema{
    Type: schema.TypeList,
    Elem: &schema.Schema{
      Type:         schema.TypeString,
      ValidateFunc: /* ... */,
    },
}

&schema.Schema{
    Type: schema.TypeSet,
    Elem: &schema.Schema{
      Type:             schema.TypeString,
      ValidateDiagFunc: /* ... */,
    },
}

Ignoring reports

Singular reports can be ignored by adding a //lintignore:S009 Go code comment at the end of the offending line or on the line immediately preceding, e.g.

//lintignore:S009
&schema.Schema{
    Type:         schema.TypeList,
    Elem:         &schema.Schema{Type: schema.TypeString},
    ValidateFunc: /* ... */,
}

This page is generated from passes/S009/README.md, which lives beside the analyzer.