Documentation
¶
Index ¶
- Variables
- func JSONSchemaValidate(schemaURL string, docJSON []byte) (bool, error)
- func ValidateXSD(b []byte, schemaPath string) (bool, error)
- type CsvValidator
- type EditorConfigValidator
- type EnvValidator
- type HclValidator
- type HoconValidator
- type IniValidator
- type JSONMarshaler
- type JSONValidator
- type PlistValidator
- type PropValidator
- type SarifValidator
- type SchemaErrors
- type SchemaValidator
- type TomlValidator
- type ToonValidator
- type ValidationError
- type Validator
- type XMLSchemaValidator
- type XMLValidator
- type YAMLValidator
Constants ¶
This section is empty.
Variables ¶
var ErrNoSchema = errors.New("no schema declared")
ErrNoSchema is returned by SchemaValidator.ValidateSchema when the document supports schema validation but does not declare a schema.
Functions ¶
Types ¶
type CsvValidator ¶
type CsvValidator struct{}
CsvValidator is used to validate a byte slice that is intended to represent a CSV file.
func (CsvValidator) ValidateSyntax ¶
func (CsvValidator) ValidateSyntax(b []byte) (bool, error)
Validate checks if the provided byte slice represents a valid .csv file. https://pkg.go.dev/encoding/csv
type EditorConfigValidator ¶
type EditorConfigValidator struct{}
func (EditorConfigValidator) ValidateSyntax ¶
func (EditorConfigValidator) ValidateSyntax(b []byte) (bool, error)
Validate implements the Validator interface by attempting to parse a byte array of an editorconfig file using editorconfig-core-go package
type EnvValidator ¶
type EnvValidator struct{}
func (EnvValidator) ValidateSyntax ¶
func (EnvValidator) ValidateSyntax(b []byte) (bool, error)
Validate implements the Validator interface by attempting to parse a byte array of a env file using envparse package
type HclValidator ¶
type HclValidator struct{}
HclValidator is used to validate a byte slice that is intended to represent a HashiCorp Configuration Language (HCL) file.
func (HclValidator) ValidateSyntax ¶
func (HclValidator) ValidateSyntax(b []byte) (bool, error)
Validate checks if the provided byte slice represents a valid .hcl file.
The hcl parser uses FIFO to determine which error to display to the user. For more information, see the documentation at:
https://pkg.go.dev/github.com/hashicorp/hcl/v2#Diagnostics.Error
If the hcl.Diagnostics slice contains more than one error, the wrapped error returned by this function will include them as "and {count} other diagnostic(s)" in the error message.
type HoconValidator ¶
type HoconValidator struct{}
HoconValidator is used to validate a byte slice that is intended to represent a HOCON file.
func (HoconValidator) ValidateSyntax ¶
func (HoconValidator) ValidateSyntax(b []byte) (bool, error)
Validate checks if the provided byte slice represents a valid .hocon file.
type IniValidator ¶
type IniValidator struct{}
func (IniValidator) ValidateSyntax ¶
func (IniValidator) ValidateSyntax(b []byte) (bool, error)
Validate implements the Validator interface by attempting to parse a byte array of ini
type JSONMarshaler ¶
JSONMarshaler is an optional interface for validators whose content can be converted to JSON for schema validation. This is used when an external schema (e.g. from SchemaStore or --schema-map) is applied to a file that does not declare its own $schema.
type JSONValidator ¶
type JSONValidator struct{}
func (JSONValidator) MarshalToJSON ¶
func (JSONValidator) MarshalToJSON(b []byte) ([]byte, error)
func (JSONValidator) ValidateSchema ¶
func (JSONValidator) ValidateSchema(b []byte, filePath string) (bool, error)
func (JSONValidator) ValidateSyntax ¶
func (JSONValidator) ValidateSyntax(b []byte) (bool, error)
type PlistValidator ¶
type PlistValidator struct{}
PlistValidator is used to validate a byte slice that is intended to represent a Apple Property List file (plist).
func (PlistValidator) ValidateSyntax ¶
func (PlistValidator) ValidateSyntax(b []byte) (bool, error)
Validate checks if the provided byte slice represents a valid .plist file.
type PropValidator ¶
type PropValidator struct{}
func (PropValidator) ValidateSyntax ¶
func (PropValidator) ValidateSyntax(b []byte) (bool, error)
Validate implements the Validator interface by attempting to parse a byte array of properties
type SarifValidator ¶
type SarifValidator struct{}
func (SarifValidator) ValidateSchema ¶
func (SarifValidator) ValidateSchema(b []byte, _ string) (bool, error)
func (SarifValidator) ValidateSyntax ¶
func (SarifValidator) ValidateSyntax(b []byte) (bool, error)
type SchemaErrors ¶
SchemaErrors holds multiple schema validation errors. The joined Error() string is used for backward compatibility, while Errors() returns individual error messages.
func (*SchemaErrors) Error ¶
func (e *SchemaErrors) Error() string
func (*SchemaErrors) Errors ¶
func (e *SchemaErrors) Errors() []string
type SchemaValidator ¶
SchemaValidator is an optional interface for validators that support schema validation. The filePath parameter is the absolute path to the file being validated, used to resolve relative schema references. ValidateSchema should return ErrNoSchema when the document does not declare a schema (e.g. no $schema property in JSON).
type TomlValidator ¶
type TomlValidator struct{}
func (TomlValidator) MarshalToJSON ¶
func (TomlValidator) MarshalToJSON(b []byte) ([]byte, error)
func (TomlValidator) ValidateSchema ¶
func (TomlValidator) ValidateSchema(b []byte, filePath string) (bool, error)
func (TomlValidator) ValidateSyntax ¶
func (TomlValidator) ValidateSyntax(b []byte) (bool, error)
type ToonValidator ¶
type ToonValidator struct{}
func (ToonValidator) MarshalToJSON ¶
func (ToonValidator) MarshalToJSON(b []byte) ([]byte, error)
func (ToonValidator) ValidateSchema ¶
func (ToonValidator) ValidateSchema(b []byte, filePath string) (bool, error)
func (ToonValidator) ValidateSyntax ¶
func (ToonValidator) ValidateSyntax(b []byte) (bool, error)
type ValidationError ¶
ValidationError wraps a validation error with optional source position. Line and Column are 1-based. A zero value means the position is unknown.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
func (*ValidationError) Unwrap ¶
func (e *ValidationError) Unwrap() error
type Validator ¶
Validator is the base interface that all validators must implement. For optional capabilities, use type assertions against SchemaValidator.
type XMLSchemaValidator ¶
XMLSchemaValidator is a marker interface for validators that use XSD schema validation instead of JSON Schema. When an external schema is applied via --schema-map or --schemastore, the CLI uses ValidateXSD instead of JSONSchemaValidate.
type XMLValidator ¶
type XMLValidator struct{}
func (XMLValidator) ValidateSchema ¶
func (XMLValidator) ValidateSchema(b []byte, filePath string) (bool, error)
func (XMLValidator) ValidateSyntax ¶
func (XMLValidator) ValidateSyntax(b []byte) (bool, error)
func (XMLValidator) ValidateXSD ¶
func (XMLValidator) ValidateXSD(b []byte, schemaPath string) (bool, error)
ValidateXSD satisfies the XMLSchemaValidator marker interface.
type YAMLValidator ¶
type YAMLValidator struct{}
func (YAMLValidator) MarshalToJSON ¶
func (YAMLValidator) MarshalToJSON(b []byte) ([]byte, error)
func (YAMLValidator) ValidateSchema ¶
func (YAMLValidator) ValidateSchema(b []byte, filePath string) (bool, error)
func (YAMLValidator) ValidateSyntax ¶
func (YAMLValidator) ValidateSyntax(b []byte) (bool, error)