parser

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2025 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Fields is the fields flag
	Fields = "$fields"

	// Errors is the errors flag
	Errors = "$errors"
)
View Source
var (
	ErrNilJSONParsedValidations = errors.New("json parsed validations is nil")
	ErrNilParser                = errors.New("mapper validations parser cannot be nil")
)

Functions

This section is empty.

Types

type ErrorParser

type ErrorParser struct{}

ErrorParser is the struct for the error parser

func NewErrorParser

func NewErrorParser() *ErrorParser

NewErrorParser creates a new ErrorParser struct

func (*ErrorParser) GenerateFailedValidationsMessage

func (e *ErrorParser) GenerateFailedValidationsMessage(
	validations govalidatorvalidations.Validations,
	level int,
) (*string, error)

GenerateFailedValidationsMessage returns a formatted error message for ErrorParser

func (*ErrorParser) GetLevelPadding

func (e *ErrorParser) GetLevelPadding(level int) string

GetLevelPadding returns the padding for the level

func (*ErrorParser) ParseValidations

func (e *ErrorParser) ParseValidations(validations govalidatorvalidations.Validations) (
	interface{},
	error,
)

ParseValidations parses the validations and returns the failed validations message

type JSONParsedValidations

type JSONParsedValidations struct {
	Fields *map[string]*JSONParsedValidations `json:"$fields,omitempty"`
	Errors *[]error                           `json:"$errors,omitempty"`
}

JSONParsedValidations is a struct that holds the JSON parsed validations

func NewJSONParsedValidations

func NewJSONParsedValidations() *JSONParsedValidations

NewJSONParsedValidations creates a new JSONParsedValidations struct

func (*JSONParsedValidations) AddErrors

func (j *JSONParsedValidations) AddErrors(errors *[]error)

AddErrors adds errors to the JSON parsed validations

func (*JSONParsedValidations) AddFieldParsedValidations

func (j *JSONParsedValidations) AddFieldParsedValidations(
	field string,
	fieldParsedValidations *JSONParsedValidations,
)

AddFieldParsedValidations adds a field parsed validations to the JSON parsed validations

func (*JSONParsedValidations) GetFieldParsedValidations

func (j *JSONParsedValidations) GetFieldParsedValidations(field string) *JSONParsedValidations

GetFieldParsedValidations returns the field parsed validations from the JSON parsed validations

type JSONParser

type JSONParser struct{}

JSONParser is a struct that holds the JSON parser

func NewJSONParser

func NewJSONParser() *JSONParser

NewJSONParser creates a new JSONParser struct

func (*JSONParser) GenerateJSONParsedValidations

func (j *JSONParser) GenerateJSONParsedValidations(
	validations govalidatorvalidations.Validations,
	jsonParsedValidations *JSONParsedValidations,
) error

GenerateJSONParsedValidations returns a

func (*JSONParser) ParseValidations

func (j *JSONParser) ParseValidations(validations govalidatorvalidations.Validations) (
	interface{},
	error,
)

ParseValidations parses the validations into JSON

type Parser

type Parser interface {
	ParseValidations(validations govalidatorvalidations.Validations) (
		interface{},
		error,
	)
}

Parser is an interface to parse struct fields validations

Jump to

Keyboard shortcuts

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