34 lines
653 B
Go
34 lines
653 B
Go
package schema
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/qri-io/jsonschema"
|
|
)
|
|
|
|
var (
|
|
ErrSchemaNotFound = errors.New("schema not found")
|
|
ErrInvalidData = errors.New("invalid data")
|
|
)
|
|
|
|
type InvalidDataError struct {
|
|
keyErrors []jsonschema.KeyError
|
|
}
|
|
|
|
func (e *InvalidDataError) Is(err error) bool {
|
|
return err == ErrInvalidData
|
|
}
|
|
|
|
func (e *InvalidDataError) Error() string {
|
|
return fmt.Sprintf("%s: %s", ErrInvalidData.Error(), e.keyErrors)
|
|
}
|
|
|
|
func (e *InvalidDataError) KeyErrors() []jsonschema.KeyError {
|
|
return e.keyErrors
|
|
}
|
|
|
|
func NewInvalidDataError(keyErrors ...jsonschema.KeyError) *InvalidDataError {
|
|
return &InvalidDataError{keyErrors}
|
|
}
|