Documentation ¶
Index ¶
Constants ¶
View Source
const ( // SchemaDefinitions is the location of the repository // of schema definitions on the filepath SchemaDefinitions = "./artifacts/json-schema" // DefinitionFile is the schema definition file, or the root // file from which a definition beings DefinitionFile = "schema.json" // CurrentVersion represents the default CurrentVersion = "1.0.0" )
Variables ¶
View Source
var ( // ErrSchemaVersionUndefined is returned if a validator is requested // and no corresponding schema definition that matches the version is present // in the SchemaDefinitions artifact repository ErrSchemaVersionUndefined = errors.New("schema version undefined") // ErrValidationFailed is returned by Validate if the supplied document // does not pass validation ErrValidationFailed = errors.New("validation failed") )
Functions ¶
This section is empty.
Types ¶
type Validator ¶
type Validator struct { Version string Valid bool DefinitionFile string // contains filtered or unexported fields }
Validator is a validator for JSON documents
func NewValidator ¶
NewValidator will return a new validator configured to use the CurrentVersion of the schema definition
func NewValidatorByVersion ¶
NewValidatorByVersion will return a new validator with the definition for the supplied version number loaded, as defined in the SchemaDefinitions repository and ready for a document to be validated against
func (*Validator) Errors ¶
func (v *Validator) Errors() []schema.ResultError
Errors returns any error objects from a failed validation
Click to show internal directories.
Click to hide internal directories.