validator-go

module
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2025 License: Apache-2.0

README

validator-go

Katydid is a validation language. validator-go is a validator for Katydid in Go.

GoDoc Build Status

Katydid Logo

Katydid consists of:

  • A validator: a regular expression type language for serialized data that matches up to 1000000s of records per second,
  • A collection of parsers (protobuf, json, xml, reflected go structures, yaml) which are easily extendable.

Usage Example

package main

import (
  "github.com/katydid/validator-go/validator"
  "github.com/katydid/parser-go-json/json"
)

func main() {
  data := json.NewJSONParser()
  err := data.Init([]byte(`
    {
      "WhatsUp": "E",
      "DragonsExist": false,
      "MonkeysSmart": true
    }`))
  ...
  ast, err := validator.Parse(".WhatsUp == "E")
  ...
  // creates memoizing validator that increases in speed the more it is used.
  mem, err := validator.Prepare(ast)
  ...
  valid, err := validator.Validate(mem, data)
  ...
  if valid {
    fmt.Printf("the serailized json contains a field WhatsUp with a value E\n")
  }
}

Directories

Path Synopsis
Package gen contains some internal utilities for code generation
Package gen contains some internal utilities for code generation
Package validator contains the validation language and the functions necessary for running it.
Package validator contains the validation language and the functions necessary for running it.
ast
Package ast contains the abstract syntax tree for the validator.
Package ast contains the abstract syntax tree for the validator.
auto
Package auto compiles a parsed validator grammar into a visual pushdown automaton and executes it.
Package auto compiles a parsed validator grammar into a visual pushdown automaton and executes it.
bnf
Package bnf contains the bnf (Backus–Naur Form) files for generating the parser, lexer, token and errors package.
Package bnf contains the bnf (Backus–Naur Form) files for generating the parser, lexer, token and errors package.
combinator
Package combinator provides a user friendly way of constructing a validator abstract syntax tree.
Package combinator provides a user friendly way of constructing a validator abstract syntax tree.
compose
Code generated by compose-gen.
Code generated by compose-gen.
compose/compose-gen command
Command compose-gen generates some of the code in the compose package.
Command compose-gen generates some of the code in the compose package.
errors
Package errors is generated from the bnf using gocc.
Package errors is generated from the bnf using gocc.
funcs
Code generated by funcs-gen.
Code generated by funcs-gen.
funcs/funcs-gen command
Command funcs-gen generates some of the code in the funcs package.
Command funcs-gen generates some of the code in the funcs package.
interp
Package interp contains functions to interpret the grammar.
Package interp contains functions to interpret the grammar.
lexer
Package lexer is generated from the bnf using gocc.
Package lexer is generated from the bnf using gocc.
mem
Package mem contains functions to interpret and memoize the execution of the grammar.
Package mem contains functions to interpret and memoize the execution of the grammar.
name
Package name has functions for a parsed name expression which include compilation and evaluation.
Package name has functions for a parsed name expression which include compilation and evaluation.
parser
Package parser is mostly generated from the bnf using gocc.
Package parser is mostly generated from the bnf using gocc.
token
Package token is generated from the bnf using gocc.
Package token is generated from the bnf using gocc.
types
Package types contains representations of the validator types.
Package types contains representations of the validator types.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL