...

Source file src/github.com/ory/x/jsonschemax/error.go

Documentation: github.com/ory/x/jsonschemax

     1  package jsonschemax
     2  
     3  import (
     4  	"github.com/ory/jsonschema/v3"
     5  )
     6  
     7  // ErrorType is the schema error type.
     8  type ErrorType int
     9  
    10  const (
    11  	// ErrorTypeMissing represents a validation that failed because a value is missing.
    12  	ErrorTypeMissing ErrorType = iota + 1
    13  )
    14  
    15  // Error represents a schema error.
    16  type Error struct {
    17  	// Type is the error type.
    18  	Type ErrorType
    19  
    20  	// DocumentPointer is the JSON Pointer in the document.
    21  	DocumentPointer string
    22  
    23  	// SchemaPointer is the JSON Pointer in the schema.
    24  	SchemaPointer string
    25  
    26  	// DocumentFieldName is a pointer to the document in dot-notation: fo.bar.baz
    27  	DocumentFieldName string
    28  }
    29  
    30  // NewFromSanthoshError converts github.com/santhosh-tekuri/jsonschema.ValidationError to Error.
    31  func NewFromSanthoshError(validationError jsonschema.ValidationError) *Error {
    32  	return &Error{
    33  		// DocumentPointer:   JSONPointerToDotNotation(validationError.InstancePtr),
    34  		// SchemaPointer:     JSONPointerToDotNotation(validationError.SchemaPtr),
    35  		// DocumentFieldName: JSONPointerToDotNotation(validationError.InstancePtr),
    36  	}
    37  }
    38  

View as plain text