jsonschema: pre-compile regexps
This is the first CL that deals with the process of preparing a schema for validation. Perform some basic checks on the scheme. Along the way, compile regexps and store them in the schema for use during validation. Change-Id: I0e5e6ce28656dcecb6d2d4b2fdc98998fa05b6f1 Reviewed-on: https://go-review.googlesource.com/c/tools/+/669696 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
cc7bdd8d43
commit
3d33fafc5d
1 changed files with 153 additions and 34 deletions
|
|
@ -13,6 +13,7 @@ import (
|
|||
"fmt"
|
||||
"iter"
|
||||
"math"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
// A Schema is a JSON schema object.
|
||||
|
|
@ -106,6 +107,10 @@ type Schema struct {
|
|||
Then *Schema `json:"then,omitempty"`
|
||||
Else *Schema `json:"else,omitempty"`
|
||||
DependentSchemas map[string]*Schema `json:"dependentSchemas,omitempty"`
|
||||
|
||||
// computed fields
|
||||
pattern *regexp.Regexp
|
||||
patternProperties map[*regexp.Regexp]*Schema
|
||||
}
|
||||
|
||||
// String returns a short description of the schema.
|
||||
|
|
|
|||
Loading…
Reference in a new issue