Documentation
¶
Overview ¶
package schema provides a mechanism to validate the structure of a CONL document.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Result ¶ added in v0.3.1
type Result struct {
// contains filtered or unexported fields
}
A Result is produced when validating a document against a Schema.
func Validate ¶ added in v0.3.0
Validate a CONL document. If load is nil (or returns nil) then Any is used. If the document contains a top-level key 'schema' then its value is passed to load, otherwise load is called with "". The Result can be queried for further information about the match.
func (*Result) DocsForKey ¶ added in v0.4.0
DocsForKey returns the docs for the key on line (1-based)
func (*Result) DocsForValue ¶ added in v0.4.0
DocsForValue returns the docs for the value on line (1-based)
func (*Result) Errors ¶ added in v0.3.1
func (r *Result) Errors() []ValidationError
Errors returns a non-empty list of errors if the result is not valid. As there are many potential ways for a schema to match a document, the exact errors returned may change over time.
func (*Result) SuggestedKeys ¶ added in v0.3.1
func (r *Result) SuggestedKeys(line int) []*Suggestion
SuggestedKeys returns possible keys for the map defined on line, or for the root of the document if line == 0. If the value defined on this line is a list, "=" is returned.
func (*Result) SuggestedValues ¶ added in v0.3.1
func (r *Result) SuggestedValues(line int) []*Suggestion
SuggestedValues returns possible values to autocomplete on line (1-based)
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
A Schema allows you to validate a CONL document against a set of rules.
type Suggestion ¶ added in v0.4.0
Suggestion is returned by Result.SuggestedKeys or Result.SuggestedValues
type ValidationError ¶
type ValidationError struct {
// contains filtered or unexported fields
}
A ValidationError represents a single validation error.
func (*ValidationError) Error ¶
func (ve *ValidationError) Error() string
Error returns the error message prefixed by the line number.
func (*ValidationError) Lno ¶
func (ve *ValidationError) Lno() int
Lno returns the line number (1-based) on which the error occurred.
func (*ValidationError) Msg ¶ added in v0.3.0
func (ve *ValidationError) Msg() string
Msg returns a human-readable description of the problem suitable for showing to end-users.