validator

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package validator contains functions to handle different schema arguments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArgTypeAny

func ArgTypeAny(fn func(arg types.PartAny, instance any, state *types.ValidationState) error) func(types.PartValue, any, *types.ValidationState) error

ArgTypeAny converts a validator function that accepts types.ArgTypeAny to one that can be stored in a types.Keyword.

func ArgTypeBool

func ArgTypeBool(fn func(arg types.PartBool, instance any, state *types.ValidationState) error) func(types.PartValue, any, *types.ValidationState) error

ArgTypeBool converts a validator function that accepts types.ArgTypeBool to one that can be stored in a types.Keyword.

func ArgTypeFloat

func ArgTypeFloat(fn func(arg types.PartFloat, instance any, state *types.ValidationState) error) func(types.PartValue, any, *types.ValidationState) error

ArgTypeFloat converts a validator function that accepts types.ArgTypeFloat to one that can be stored in a types.Keyword.

func ArgTypeInt

func ArgTypeInt(fn func(arg types.PartInt, instance any, state *types.ValidationState) error) func(types.PartValue, any, *types.ValidationState) error

ArgTypeInt converts a validator function that accepts types.ArgTypeInt to one that can be stored in a types.Keyword.

func ArgTypeMapArrayOrSchema

func ArgTypeMapArrayOrSchema(fn func(arg types.PartMapArrayOrSchema, instance any, state *types.ValidationState) error) func(types.PartValue, any, *types.ValidationState) error

ArgTypeMapArrayOrSchema converts a validator function that accepts types.ArgTypeMapArrayOrSchema to one that can be stored in a types.Keyword.

func ArgTypeMapSchema

func ArgTypeMapSchema(fn func(arg types.PartMapSchema, instance any, state *types.ValidationState) error) func(types.PartValue, any, *types.ValidationState) error

ArgTypeMapSchema converts a validator function that accepts types.ArgTypeMapSchema to one that can be stored in a types.Keyword.

func ArgTypeSchema

func ArgTypeSchema(fn func(arg types.PartSchema, instance any, state *types.ValidationState) error) func(types.PartValue, any, *types.ValidationState) error

ArgTypeSchema converts a validator function that accepts types.ArgTypeSchema to one that can be stored in a types.Keyword.

func ArgTypeSchemaOrSchemas

func ArgTypeSchemaOrSchemas(fn func(arg types.PartSchemaOrSchemas, instance any, state *types.ValidationState) error) func(types.PartValue, any, *types.ValidationState) error

ArgTypeSchemaOrSchemas converts a validator function that accepts types.ArgTypeSchemaOrSchemas to one that can be stored in a types.Keyword.

func ArgTypeSchemas

func ArgTypeSchemas(fn func(arg types.PartSchemas, instance any, state *types.ValidationState) error) func(types.PartValue, any, *types.ValidationState) error

ArgTypeSchemas converts a validator function that accepts types.ArgTypeSchemas to one that can be stored in a types.Keyword.

func ArgTypeString

func ArgTypeString(fn func(arg types.PartString, instance any, state *types.ValidationState) error) func(types.PartValue, any, *types.ValidationState) error

ArgTypeString converts a validator function that accepts types.ArgTypeString to one that can be stored in a types.Keyword.

func ArgTypeStringOrStrings

func ArgTypeStringOrStrings(fn func(arg types.PartStringOrStrings, instance any, state *types.ValidationState) error) func(types.PartValue, any, *types.ValidationState) error

ArgTypeStringOrStrings converts a validator function that accepts types.ArgTypeStringOrStrings to one that can be stored in a types.Keyword.

func ArgTypeStrings

func ArgTypeStrings(fn func(arg types.PartStrings, instance any, state *types.ValidationState) error) func(types.PartValue, any, *types.ValidationState) error

ArgTypeStrings converts a validator function that accepts types.ArgTypeStrings to one that can be stored in a types.Keyword.

func RegisterFormatValidator

func RegisterFormatValidator(format string, fv formatValidator)

RegisterFormatValidator records a validator to use for a format keyword.

func ToAny

func ToAny(arg types.PartValue) (types.PartAny, error)

ToAny converts arg into a types.PartAny.

func ToBool

func ToBool(arg types.PartValue) (types.PartBool, error)

ToBool converts arg into a types.PartBool.

func ToFloat

func ToFloat(arg types.PartValue) (types.PartFloat, error)

ToFloat converts arg into a types.PartFloat.

func ToInt

func ToInt(arg types.PartValue) (types.PartInt, error)

ToInt converts arg into a types.PartInt.

func ToMapArrayOrSchema

func ToMapArrayOrSchema(arg types.PartValue) (types.PartMapArrayOrSchema, error)

ToMapArrayOrSchema converts arg into a types.PartMapArrayOrSchema.

func ToMapSchema

func ToMapSchema(arg types.PartValue) (types.PartMapSchema, error)

ToMapSchema converts arg into a types.PartMapSchema.

func ToSchema

func ToSchema(arg types.PartValue) (types.PartSchema, error)

ToSchema converts arg into a types.PartSchema.

func ToSchemaOrSchemas

func ToSchemaOrSchemas(arg types.PartValue) (types.PartSchemaOrSchemas, error)

ToSchemaOrSchemas converts arg into a types.PartSchemaOrSchemas.

func ToSchemas

func ToSchemas(arg types.PartValue) (types.PartSchemas, error)

ToSchemas converts arg into a types.PartSchemas.

func ToString

func ToString(arg types.PartValue) (types.PartString, error)

ToString converts arg into a types.PartString.

func ToStringOrStrings

func ToStringOrStrings(arg types.PartValue) (types.PartStringOrStrings, error)

ToStringOrStrings converts arg into a types.PartStringOrStrings.

func ToStrings

func ToStrings(arg types.PartValue) (types.PartStrings, error)

ToStrings converts arg into a types.PartStrings.

func ValidateAdditionalProperties

func ValidateAdditionalProperties(arg types.PartSchema, instance any, state *types.ValidationState) error

ValidateAdditionalProperties implements the additionalProperties keyword.

func ValidateAllOf

func ValidateAllOf(arg types.PartSchemas, instance any, state *types.ValidationState) error

ValidateAllOf implements the allOf keyword.

func ValidateAnyOf

func ValidateAnyOf(arg types.PartSchemas, instance any, state *types.ValidationState) error

ValidateAnyOf implements the anyOf keyword.

func ValidateConst

func ValidateConst(arg types.PartAny, instance any, state *types.ValidationState) error

ValidateConst implements the const keyword.

func ValidateContains

func ValidateContains(arg types.PartSchema, instance any, state *types.ValidationState) error

ValidateContains implements the contains keyword.

func ValidateDefault

func ValidateDefault(arg types.PartAny, instance any, state *types.ValidationState) error

ValidateDefault implements the default keyword.

func ValidateDependencies

func ValidateDependencies(arg types.PartMapArrayOrSchema, instance any, state *types.ValidationState) error

ValidateDependencies validates the draft7 dependencies keyword. This is also used for later drafts, as an optional feature.

func ValidateDependentRequired

func ValidateDependentRequired(arg types.PartAny, instance any, state *types.ValidationState) error

ValidateDependentRequired implements the dependentRequired keyword.

func ValidateDependentSchemas

func ValidateDependentSchemas(arg types.PartMapSchema, instance any, state *types.ValidationState) error

ValidateDependentSchemas implements the dependentSchemas keyword.

func ValidateElse

func ValidateElse(arg types.PartSchema, instance any, state *types.ValidationState) error

ValidateElse implements the else keyword.

func ValidateEnum

func ValidateEnum(arg types.PartAny, instance any, state *types.ValidationState) error

ValidateEnum implements the enum keyword.

func ValidateExclusiveMaximum

func ValidateExclusiveMaximum(arg types.PartFloat, instance any, state *types.ValidationState) error

ValidateExclusiveMaximum implements the exclusiveMaximum keyword.

func ValidateExclusiveMinimum

func ValidateExclusiveMinimum(arg types.PartFloat, instance any, state *types.ValidationState) error

ValidateExclusiveMinimum implements the exclusiveMinimum keyword.

func ValidateFormat

func ValidateFormat(arg types.PartString, instance any, state *types.ValidationState) error

ValidateFormat implements the format keyword.

func ValidateIf

func ValidateIf(arg types.PartSchema, instance any, state *types.ValidationState) error

ValidateIf implements the if keyword. This is always valid, but records a note for the "then" and "else" keywords.

func ValidateItems

func ValidateItems(arg types.PartSchema, instance any, state *types.ValidationState) error

ValidateItems implements the items keyword.

func ValidateMaxContains

func ValidateMaxContains(arg types.PartInt, instance any, state *types.ValidationState) error

ValidateMaxContains implements the maxContains keyword.

func ValidateMaxItems

func ValidateMaxItems(arg types.PartInt, instance any, state *types.ValidationState) error

ValidateMaxItems implements the maxItems keyword.

func ValidateMaxLength

func ValidateMaxLength(arg types.PartInt, instance any, state *types.ValidationState) error

ValidateMaxLength implements the maxLength keyword.

func ValidateMaxProperties

func ValidateMaxProperties(arg types.PartInt, instance any, state *types.ValidationState) error

ValidateMaxProperties implements the maxProperties keyword.

func ValidateMaximum

func ValidateMaximum(arg types.PartFloat, instance any, state *types.ValidationState) error

ValidateMaximum implements the maximum keyword.

func ValidateMinContains

func ValidateMinContains(arg types.PartInt, instance any, state *types.ValidationState) error

ValidateMinContains implements the minContains keyword.

func ValidateMinItems

func ValidateMinItems(arg types.PartInt, instance any, state *types.ValidationState) error

ValidateMinItems implements the minItems keyword.

func ValidateMinLength

func ValidateMinLength(arg types.PartInt, instance any, state *types.ValidationState) error

ValidateMinLength implements the minLength keyword.

func ValidateMinProperties

func ValidateMinProperties(arg types.PartInt, instance any, state *types.ValidationState) error

ValidateMinProperties implements the minProperties keyword.

func ValidateMinimum

func ValidateMinimum(arg types.PartFloat, instance any, state *types.ValidationState) error

ValidateMinimum implements the minimum keyword.

func ValidateMultipleOf

func ValidateMultipleOf(arg types.PartFloat, instance any, state *types.ValidationState) error

ValidateMultipleOf implements the multipleOf keyword.

func ValidateNot

func ValidateNot(arg types.PartSchema, instance any, state *types.ValidationState) error

ValidateNot implements the not keyword.

func ValidateOneOf

func ValidateOneOf(arg types.PartSchemas, instance any, state *types.ValidationState) error

ValidateOneOf implements the oneOf keyword.

func ValidatePattern

func ValidatePattern(arg types.PartString, instance any, state *types.ValidationState) error

ValidatePattern implements the pattern keyword.

func ValidatePatternProperties

func ValidatePatternProperties(arg types.PartMapSchema, instance any, state *types.ValidationState) error

ValidatePatternProperties implements the patternProperties keyword.

func ValidatePrefixItems

func ValidatePrefixItems(arg types.PartSchemas, instance any, state *types.ValidationState) error

ValidatePrefixItems implements the prefixItems keyword.

func ValidateProperties

func ValidateProperties(arg types.PartMapSchema, instance any, state *types.ValidationState) error

ValidateProperties implements the properties keyword.

func ValidatePropertyNames

func ValidatePropertyNames(arg types.PartSchema, instance any, state *types.ValidationState) error

ValidatePropertyNames implements the propertyNames keyword.

func ValidateRequired

func ValidateRequired(arg types.PartStrings, instance any, state *types.ValidationState) error

ValidateRequired implements the required keyword.

func ValidateThen

func ValidateThen(arg types.PartSchema, instance any, state *types.ValidationState) error

ValidateThen implements the then keyword.

func ValidateTrue

func ValidateTrue(types.PartValue, any, *types.ValidationState) error

ValidateTrue is used for keywords that always match. These keywords have meaning for the schema, but don't affect whether the schema validates an instance.

func ValidateType

func ValidateType(arg types.PartStringOrStrings, instance any, state *types.ValidationState) error

ValidateType implements the type keyword.

func ValidateUnevaluatedItems

func ValidateUnevaluatedItems(arg types.PartSchema, instance any, state *types.ValidationState) error

ValidateUnevaluatedItems implements the unevaluatedItems keyword.

func ValidateUnevaluatedProperties

func ValidateUnevaluatedProperties(arg types.PartSchema, instance any, state *types.ValidationState) error

ValidateUnevaluatedProperties implements the unevaluatedProperties keyword.

func ValidateUniqueItems

func ValidateUniqueItems(arg types.PartBool, instance any, state *types.ValidationState) error

ValidateUniqueItems implements the uniqueItems keyword.

Types

This section is empty.

Jump to

Keyboard shortcuts

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