Documentation ¶
Index ¶
- func ValidateValue(value interface{}) error
- func ValidateValueWithMessage(value interface{}, msg string) error
- type AggregatedError
- type Context
- type Error
- type FormatAbsolutePath
- type FormatAlpha2
- type FormatBCP47
- type FormatBase64URL
- type FormatBirthdate
- type FormatContractID
- type FormatCustomAttributePointer
- type FormatDateTime
- type FormatDurationString
- type FormatEmail
- type FormatGoogleTagManagerContainerID
- type FormatHTTPOrigin
- type FormatHTTPOriginSpec
- type FormatHookURI
- type FormatLDAPAttribute
- type FormatLDAPDN
- type FormatLDAPSearchFilterTemplate
- type FormatLDAPURL
- type FormatNetworkID
- type FormatPhone
- type FormatPicture
- type FormatRe2Regex
- type FormatTimezone
- type FormatURI
- type FormatWeChatAccountID
- type FormatX509CertPem
- type MultipartSchema
- func (s *MultipartSchema) Add(partID string, schema string) *MultipartSchema
- func (s *MultipartSchema) AddJSON(partID string, schema interface{}) *MultipartSchema
- func (s *MultipartSchema) DumpSchemaString(pretty bool) (schemaString string, err error)
- func (s *MultipartSchema) Instantiate() *MultipartSchema
- func (s *MultipartSchema) PartValidator(partID string) *SchemaValidator
- func (s *MultipartSchema) RegisterFormat(format string, checker jsonschemaformat.FormatChecker)
- func (s *MultipartSchema) Validator() *SchemaValidator
- type SchemaBuilder
- func (b SchemaBuilder) AddRequired(keys ...string) SchemaBuilder
- func (b SchemaBuilder) AddTypeNull() SchemaBuilder
- func (b SchemaBuilder) AdditionalPropertiesFalse() SchemaBuilder
- func (b SchemaBuilder) AllOf(builders ...SchemaBuilder) SchemaBuilder
- func (b SchemaBuilder) Clone() SchemaBuilder
- func (b SchemaBuilder) Const(value interface{}) SchemaBuilder
- func (b SchemaBuilder) Contains(builder SchemaBuilder) SchemaBuilder
- func (b SchemaBuilder) Else(builder SchemaBuilder) SchemaBuilder
- func (b SchemaBuilder) Enum(values ...interface{}) SchemaBuilder
- func (b SchemaBuilder) Format(format string) SchemaBuilder
- func (b SchemaBuilder) If(builder SchemaBuilder) SchemaBuilder
- func (b SchemaBuilder) Items(builder SchemaBuilder) SchemaBuilder
- func (b SchemaBuilder) MaximumFloat64(maximum float64) SchemaBuilder
- func (b SchemaBuilder) MaximumInt64(maximum int64) SchemaBuilder
- func (b SchemaBuilder) MinItems(n int) SchemaBuilder
- func (b SchemaBuilder) MinLength(minLength int) SchemaBuilder
- func (b SchemaBuilder) MinimumFloat64(minimum float64) SchemaBuilder
- func (b SchemaBuilder) MinimumInt64(minimum int64) SchemaBuilder
- func (b SchemaBuilder) OneOf(builders ...SchemaBuilder) SchemaBuilder
- func (b SchemaBuilder) Properties() SchemaBuilder
- func (b SchemaBuilder) Property(key string, builder SchemaBuilder) SchemaBuilder
- func (b SchemaBuilder) Required(keys ...string) SchemaBuilder
- func (b SchemaBuilder) Then(builder SchemaBuilder) SchemaBuilder
- func (b SchemaBuilder) ToSimpleSchema() *SimpleSchema
- func (b SchemaBuilder) Type(t Type) SchemaBuilder
- func (b SchemaBuilder) Types(ts ...Type) SchemaBuilder
- type SchemaValidator
- func (v *SchemaValidator) Parse(r io.Reader, value interface{}) error
- func (v *SchemaValidator) ParseJSONRawMessage(msg json.RawMessage, value interface{}) error
- func (v *SchemaValidator) ParseWithMessage(r io.Reader, msg string, value interface{}) error
- func (v *SchemaValidator) Validate(r io.Reader) error
- func (v *SchemaValidator) ValidateValue(value interface{}) error
- func (v *SchemaValidator) ValidateValueWithMessage(value interface{}, msg string) error
- func (v *SchemaValidator) ValidateWithMessage(r io.Reader, msg string) error
- type SimpleSchema
- type Type
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateValue ¶
func ValidateValue(value interface{}) error
Types ¶
type AggregatedError ¶
func (*AggregatedError) Error ¶
func (e *AggregatedError) Error() string
func (*AggregatedError) Subtract ¶
func (e *AggregatedError) Subtract(that *AggregatedError) *AggregatedError
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func (*Context) EmitErrorMessage ¶
type Error ¶
type FormatAbsolutePath ¶
type FormatAbsolutePath struct{}
func (FormatAbsolutePath) CheckFormat ¶
func (FormatAbsolutePath) CheckFormat(value interface{}) error
type FormatAlpha2 ¶
type FormatAlpha2 struct{}
func (FormatAlpha2) CheckFormat ¶
func (FormatAlpha2) CheckFormat(value interface{}) error
type FormatBCP47 ¶
type FormatBCP47 struct{}
func (FormatBCP47) CheckFormat ¶
func (f FormatBCP47) CheckFormat(value interface{}) error
type FormatBase64URL ¶
type FormatBase64URL struct{}
func (FormatBase64URL) CheckFormat ¶
func (FormatBase64URL) CheckFormat(value interface{}) error
type FormatBirthdate ¶
type FormatBirthdate struct{}
func (FormatBirthdate) CheckFormat ¶
func (FormatBirthdate) CheckFormat(value interface{}) error
type FormatContractID ¶
type FormatContractID struct{}
func (FormatContractID) CheckFormat ¶
func (FormatContractID) CheckFormat(value interface{}) error
type FormatCustomAttributePointer ¶
type FormatCustomAttributePointer struct{}
func (FormatCustomAttributePointer) CheckFormat ¶
func (FormatCustomAttributePointer) CheckFormat(value interface{}) error
type FormatDateTime ¶
type FormatDateTime struct{}
func (FormatDateTime) CheckFormat ¶
func (FormatDateTime) CheckFormat(value interface{}) error
type FormatDurationString ¶
type FormatDurationString struct{}
func (FormatDurationString) CheckFormat ¶
func (FormatDurationString) CheckFormat(value interface{}) error
type FormatEmail ¶
type FormatEmail struct {
AllowName bool
}
FormatEmail checks if input is an email address. If the input is not a string, it is not an error. To enforce string, use other JSON schema constructs. This design allows this format to validate optional email.
func (FormatEmail) CheckFormat ¶
func (f FormatEmail) CheckFormat(value interface{}) error
type FormatGoogleTagManagerContainerID ¶
type FormatGoogleTagManagerContainerID struct{}
func (FormatGoogleTagManagerContainerID) CheckFormat ¶
func (FormatGoogleTagManagerContainerID) CheckFormat(value interface{}) error
type FormatHTTPOrigin ¶
type FormatHTTPOrigin struct { }
FormatHTTPOrigin checks if input is a valid origin with http/https scheme, host and optional port only.
func (FormatHTTPOrigin) CheckFormat ¶
func (f FormatHTTPOrigin) CheckFormat(value interface{}) error
type FormatHTTPOriginSpec ¶
type FormatHTTPOriginSpec struct{}
func (FormatHTTPOriginSpec) CheckFormat ¶
func (FormatHTTPOriginSpec) CheckFormat(value interface{}) error
type FormatHookURI ¶
type FormatHookURI struct{}
func (FormatHookURI) CheckFormat ¶
func (FormatHookURI) CheckFormat(value interface{}) error
type FormatLDAPAttribute ¶
type FormatLDAPAttribute struct{}
func (FormatLDAPAttribute) CheckFormat ¶
func (FormatLDAPAttribute) CheckFormat(value interface{}) error
type FormatLDAPDN ¶
type FormatLDAPDN struct{}
func (FormatLDAPDN) CheckFormat ¶
func (FormatLDAPDN) CheckFormat(value interface{}) error
type FormatLDAPSearchFilterTemplate ¶
type FormatLDAPSearchFilterTemplate struct{}
func (FormatLDAPSearchFilterTemplate) CheckFormat ¶
func (FormatLDAPSearchFilterTemplate) CheckFormat(value interface{}) error
type FormatLDAPURL ¶
type FormatLDAPURL struct{}
func (FormatLDAPURL) CheckFormat ¶
func (FormatLDAPURL) CheckFormat(value interface{}) error
type FormatNetworkID ¶
type FormatNetworkID struct{}
func (FormatNetworkID) CheckFormat ¶
func (FormatNetworkID) CheckFormat(value interface{}) error
type FormatPhone ¶
type FormatPhone struct{}
FormatPhone checks if input is a phone number in E.164 format. If the input is not a string, it is not an error. To enforce string, use other JSON schema constructs. This design allows this format to validate optional phone number.
func (FormatPhone) CheckFormat ¶
func (f FormatPhone) CheckFormat(value interface{}) error
type FormatPicture ¶
type FormatPicture struct{}
func (FormatPicture) CheckFormat ¶
func (FormatPicture) CheckFormat(value interface{}) error
type FormatRe2Regex ¶
type FormatRe2Regex struct{}
func (FormatRe2Regex) CheckFormat ¶
func (FormatRe2Regex) CheckFormat(value interface{}) error
type FormatTimezone ¶
type FormatTimezone struct{}
func (FormatTimezone) CheckFormat ¶
func (FormatTimezone) CheckFormat(value interface{}) error
type FormatURI ¶
type FormatURI struct { }
FormatURI checks if input is an absolute URI.
func (FormatURI) CheckFormat ¶
type FormatWeChatAccountID ¶
type FormatWeChatAccountID struct { }
FormatWeChatAccountID checks if input start with gh_.
func (FormatWeChatAccountID) CheckFormat ¶
func (f FormatWeChatAccountID) CheckFormat(value interface{}) error
type FormatX509CertPem ¶
type FormatX509CertPem struct{}
func (FormatX509CertPem) CheckFormat ¶
func (FormatX509CertPem) CheckFormat(value interface{}) error
type MultipartSchema ¶
type MultipartSchema struct {
// contains filtered or unexported fields
}
func NewMultipartSchema ¶
func NewMultipartSchema(mainPartID string) *MultipartSchema
func (*MultipartSchema) Add ¶
func (s *MultipartSchema) Add(partID string, schema string) *MultipartSchema
func (*MultipartSchema) AddJSON ¶
func (s *MultipartSchema) AddJSON(partID string, schema interface{}) *MultipartSchema
func (*MultipartSchema) DumpSchemaString ¶
func (s *MultipartSchema) DumpSchemaString(pretty bool) (schemaString string, err error)
func (*MultipartSchema) Instantiate ¶
func (s *MultipartSchema) Instantiate() *MultipartSchema
func (*MultipartSchema) PartValidator ¶
func (s *MultipartSchema) PartValidator(partID string) *SchemaValidator
func (*MultipartSchema) RegisterFormat ¶
func (s *MultipartSchema) RegisterFormat(format string, checker jsonschemaformat.FormatChecker)
func (*MultipartSchema) Validator ¶
func (s *MultipartSchema) Validator() *SchemaValidator
type SchemaBuilder ¶
type SchemaBuilder map[string]interface{}
SchemaBuilder is just map[string]interface{} with some convenient methods to build schema interactively. The zero value of a SchemaBuilder is an empty schema (by definition). This is NOT meant to be complete. It just supports the internal use cases we have.
func (SchemaBuilder) AddRequired ¶
func (b SchemaBuilder) AddRequired(keys ...string) SchemaBuilder
func (SchemaBuilder) AddTypeNull ¶
func (b SchemaBuilder) AddTypeNull() SchemaBuilder
func (SchemaBuilder) AdditionalPropertiesFalse ¶
func (b SchemaBuilder) AdditionalPropertiesFalse() SchemaBuilder
func (SchemaBuilder) AllOf ¶
func (b SchemaBuilder) AllOf(builders ...SchemaBuilder) SchemaBuilder
func (SchemaBuilder) Clone ¶
func (b SchemaBuilder) Clone() SchemaBuilder
This function allow copying the schema builder to a reference Expected usage is to avoid mutating original schema builder
func (SchemaBuilder) Const ¶
func (b SchemaBuilder) Const(value interface{}) SchemaBuilder
func (SchemaBuilder) Contains ¶
func (b SchemaBuilder) Contains(builder SchemaBuilder) SchemaBuilder
func (SchemaBuilder) Else ¶
func (b SchemaBuilder) Else(builder SchemaBuilder) SchemaBuilder
func (SchemaBuilder) Enum ¶
func (b SchemaBuilder) Enum(values ...interface{}) SchemaBuilder
func (SchemaBuilder) Format ¶
func (b SchemaBuilder) Format(format string) SchemaBuilder
func (SchemaBuilder) If ¶
func (b SchemaBuilder) If(builder SchemaBuilder) SchemaBuilder
func (SchemaBuilder) Items ¶
func (b SchemaBuilder) Items(builder SchemaBuilder) SchemaBuilder
func (SchemaBuilder) MaximumFloat64 ¶
func (b SchemaBuilder) MaximumFloat64(maximum float64) SchemaBuilder
func (SchemaBuilder) MaximumInt64 ¶
func (b SchemaBuilder) MaximumInt64(maximum int64) SchemaBuilder
func (SchemaBuilder) MinItems ¶
func (b SchemaBuilder) MinItems(n int) SchemaBuilder
func (SchemaBuilder) MinLength ¶
func (b SchemaBuilder) MinLength(minLength int) SchemaBuilder
func (SchemaBuilder) MinimumFloat64 ¶
func (b SchemaBuilder) MinimumFloat64(minimum float64) SchemaBuilder
func (SchemaBuilder) MinimumInt64 ¶
func (b SchemaBuilder) MinimumInt64(minimum int64) SchemaBuilder
func (SchemaBuilder) OneOf ¶
func (b SchemaBuilder) OneOf(builders ...SchemaBuilder) SchemaBuilder
func (SchemaBuilder) Properties ¶
func (b SchemaBuilder) Properties() SchemaBuilder
func (SchemaBuilder) Property ¶
func (b SchemaBuilder) Property(key string, builder SchemaBuilder) SchemaBuilder
func (SchemaBuilder) Required ¶
func (b SchemaBuilder) Required(keys ...string) SchemaBuilder
func (SchemaBuilder) Then ¶
func (b SchemaBuilder) Then(builder SchemaBuilder) SchemaBuilder
func (SchemaBuilder) ToSimpleSchema ¶
func (b SchemaBuilder) ToSimpleSchema() *SimpleSchema
func (SchemaBuilder) Type ¶
func (b SchemaBuilder) Type(t Type) SchemaBuilder
func (SchemaBuilder) Types ¶
func (b SchemaBuilder) Types(ts ...Type) SchemaBuilder
type SchemaValidator ¶
type SchemaValidator struct { Schema *jsonschema.Collection Reference string }
func (*SchemaValidator) Parse ¶
func (v *SchemaValidator) Parse(r io.Reader, value interface{}) error
func (*SchemaValidator) ParseJSONRawMessage ¶
func (v *SchemaValidator) ParseJSONRawMessage(msg json.RawMessage, value interface{}) error
func (*SchemaValidator) ParseWithMessage ¶
func (v *SchemaValidator) ParseWithMessage(r io.Reader, msg string, value interface{}) error
func (*SchemaValidator) ValidateValue ¶
func (v *SchemaValidator) ValidateValue(value interface{}) error
func (*SchemaValidator) ValidateValueWithMessage ¶
func (v *SchemaValidator) ValidateValueWithMessage(value interface{}, msg string) error
func (*SchemaValidator) ValidateWithMessage ¶
func (v *SchemaValidator) ValidateWithMessage(r io.Reader, msg string) error
type SimpleSchema ¶
type SimpleSchema struct {
// contains filtered or unexported fields
}
func NewSimpleSchema ¶
func NewSimpleSchema(schema string) *SimpleSchema
func (*SimpleSchema) RegisterFormat ¶
func (s *SimpleSchema) RegisterFormat(format string, checker jsonschemaformat.FormatChecker)
func (*SimpleSchema) Validator ¶
func (s *SimpleSchema) Validator() *SchemaValidator