Documentation
¶
Index ¶
- type Enum
- type Option
- type Schema
- func (*Schema) AddRule(string, jschema.Rule) error
- func (s *Schema) AddType(name string, sc jschema.Schema) (err error)
- func (s *Schema) Build() error
- func (s *Schema) Check() (err error)
- func (s *Schema) Example() (b []byte, err error)
- func (s *Schema) GetAST() (an jschema.ASTNode, err error)
- func (s *Schema) Len() (uint, error)
- func (s *Schema) UsedUserTypes() ([]string, error)
- func (s *Schema) Validate(document jschema.Document) (err error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(s *Schema)
func AllowTrailingNonSpaceCharacters ¶
func AllowTrailingNonSpaceCharacters() Option
func KeysAreOptionalByDefault ¶
func KeysAreOptionalByDefault() Option
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Example ¶
s := New("root", []byte(`{"foo": @Fizz,"bar": @Buzz}`))
l, err := s.Len()
if err != nil {
fmt.Printf("Error: %s\n", err)
return
}
fmt.Println(l)
err = s.AddType("@Fizz", New("fizz", []byte(`{"fizz": 1}`)))
if err != nil {
fmt.Printf("Error: %s\n", err)
return
}
err = s.AddType("@Buzz", New("buzz", []byte(`{"buzz": 2}`)))
if err != nil {
fmt.Printf("Error: %s\n", err)
return
}
err = s.Check()
if err != nil {
fmt.Printf("Error: %s\n", err)
return
}
err = s.Validate(json.New("json", []byte(`{"foo":{"fizz":42},"bar":{"buzz":42}}`)))
if err != nil {
fmt.Printf("Error: %s\n", err)
return
}
Output: 27
func (*Schema) UsedUserTypes ¶
Click to show internal directories.
Click to hide internal directories.