validator

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: MIT, BSD-3-Clause Imports: 16 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 schema.PartAny, instance any, state *schema.ValidationState) error) func(schema.PartValue, any, *schema.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 schema.PartBool, instance any, state *schema.ValidationState) error) func(schema.PartValue, any, *schema.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 schema.PartFloat, instance any, state *schema.ValidationState) error) func(schema.PartValue, any, *schema.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 schema.PartInt, instance any, state *schema.ValidationState) error) func(schema.PartValue, any, *schema.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 schema.PartMapArrayOrSchema, instance any, state *schema.ValidationState) error) func(schema.PartValue, any, *schema.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 schema.PartMapSchema, instance any, state *schema.ValidationState) error) func(schema.PartValue, any, *schema.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 schema.PartSchema, instance any, state *schema.ValidationState) error) func(schema.PartValue, any, *schema.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 schema.PartSchemaOrSchemas, instance any, state *schema.ValidationState) error) func(schema.PartValue, any, *schema.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 schema.PartSchemas, instance any, state *schema.ValidationState) error) func(schema.PartValue, any, *schema.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 schema.PartString, instance any, state *schema.ValidationState) error) func(schema.PartValue, any, *schema.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 schema.PartStringOrStrings, instance any, state *schema.ValidationState) error) func(schema.PartValue, any, *schema.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 schema.PartStrings, instance any, state *schema.ValidationState) error) func(schema.PartValue, any, *schema.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 schema.PartValue) (schema.PartAny, error)

ToAny converts arg into a [types.PartAny].

func ToBool

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

ToBool converts arg into a [types.PartBool].

func ToFloat

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

ToFloat converts arg into a types.PartFloat.

func ToInt

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

ToInt converts arg into a types.PartInt.

func ToMapArrayOrSchema

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

ToMapArrayOrSchema converts arg into a [types.PartMapArrayOrSchema].

func ToMapSchema

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

ToMapSchema converts arg into a [types.PartMapSchema].

func ToSchema

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

ToSchema converts arg into a [types.PartSchema].

func ToSchemaOrSchemas

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

ToSchemaOrSchemas converts arg into a [types.PartSchemaOrSchemas].

func ToSchemas

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

ToSchemas converts arg into a [types.PartSchemas].

func ToString

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

ToString converts arg into a [types.PartString].

func ToStringOrStrings

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

ToStringOrStrings converts arg into a [types.PartStringOrStrings].

func ToStrings

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

ToStrings converts arg into a [types.PartStrings].

func ValidateAdditionalProperties

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

ValidateAdditionalProperties implements the additionalProperties keyword.

func ValidateAllOf

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

ValidateAllOf implements the allOf keyword.

func ValidateAnyOf

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

ValidateAnyOf implements the anyOf keyword.

func ValidateConst

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

ValidateConst implements the const keyword.

func ValidateContains

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

ValidateContains implements the contains keyword.

func ValidateDefault

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

ValidateDefault implements the default keyword.

func ValidateDependencies

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

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

func ValidateDependentRequired

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

ValidateDependentRequired implements the dependentRequired keyword.

func ValidateDependentSchemas

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

ValidateDependentSchemas implements the dependentSchemas keyword.

func ValidateElse

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

ValidateElse implements the else keyword.

func ValidateEnum

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

ValidateEnum implements the enum keyword.

func ValidateExclusiveMaximum

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

ValidateExclusiveMaximum implements the exclusiveMaximum keyword.

func ValidateExclusiveMinimum

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

ValidateExclusiveMinimum implements the exclusiveMinimum keyword.

func ValidateFormat

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

ValidateFormat implements the format keyword.

func ValidateIf

func ValidateIf(arg schema.PartSchema, instance any, state *schema.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 schema.PartSchema, instance any, state *schema.ValidationState) error

ValidateItems implements the items keyword.

func ValidateMaxContains

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

ValidateMaxContains implements the maxContains keyword.

func ValidateMaxItems

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

ValidateMaxItems implements the maxItems keyword.

func ValidateMaxLength

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

ValidateMaxLength implements the maxLength keyword.

func ValidateMaxProperties

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

ValidateMaxProperties implements the maxProperties keyword.

func ValidateMaximum

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

ValidateMaximum implements the maximum keyword.

func ValidateMinContains

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

ValidateMinContains implements the minContains keyword.

func ValidateMinItems

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

ValidateMinItems implements the minItems keyword.

func ValidateMinLength

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

ValidateMinLength implements the minLength keyword.

func ValidateMinProperties

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

ValidateMinProperties implements the minProperties keyword.

func ValidateMinimum

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

ValidateMinimum implements the minimum keyword.

func ValidateMultipleOf

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

ValidateMultipleOf implements the multipleOf keyword.

func ValidateNot

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

ValidateNot implements the not keyword.

func ValidateOneOf

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

ValidateOneOf implements the oneOf keyword.

func ValidatePattern

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

ValidatePattern implements the pattern keyword.

func ValidatePatternProperties

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

ValidatePatternProperties implements the patternProperties keyword.

func ValidatePrefixItems

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

ValidatePrefixItems implements the prefixItems keyword.

func ValidateProperties

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

ValidateProperties implements the properties keyword.

func ValidatePropertyNames

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

ValidatePropertyNames implements the propertyNames keyword.

func ValidateRequired

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

ValidateRequired implements the required keyword.

func ValidateThen

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

ValidateThen implements the then keyword.

func ValidateTrue

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 schema.PartStringOrStrings, instance any, state *schema.ValidationState) error

ValidateType implements the type keyword.

func ValidateUnevaluatedItems

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

ValidateUnevaluatedItems implements the unevaluatedItems keyword.

func ValidateUnevaluatedProperties

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

ValidateUnevaluatedProperties implements the unevaluatedProperties keyword.

func ValidateUniqueItems

func ValidateUniqueItems(arg schema.PartBool, instance any, state *schema.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