Documentation ¶
Index ¶
- func NewGoPlaygroundValidator[Model any](rules map[string]any) *goPlaygroundValidator[Model]
- func TransformError(err *jsonschema.ValidationError) map[string][]string
- type MissingSerializer
- func (s *MissingSerializer[Model]) FromDB(raw map[string]any, ctx *gin.Context) (models.InternalValue, error)
- func (s *MissingSerializer[Model]) ToInternalValue(raw map[string]any, ctx *gin.Context) (models.InternalValue, error)
- func (s *MissingSerializer[Model]) ToRepresentation(intVal models.InternalValue, ctx *gin.Context) (Representation, error)
- type ModelSerializer
- func (s *ModelSerializer[Model]) ToInternalValue(raw map[string]any, ctx *gin.Context) (models.InternalValue, error)
- func (s *ModelSerializer[Model]) ToRepresentation(intVal models.InternalValue, ctx *gin.Context) (Representation, error)
- func (s *ModelSerializer[Model]) Validate(intVal models.InternalValue, ctx *gin.Context) error
- func (s *ModelSerializer[Model]) WithField(name string, updateFunc func(oldField *fields.Field[Model])) *ModelSerializer[Model]
- func (s *ModelSerializer[Model]) WithModelFields(passedFields []string) *ModelSerializer[Model]
- func (s *ModelSerializer[Model]) WithNewField(field *fields.Field[Model]) *ModelSerializer[Model]
- type Representation
- type Serializer
- type ValidatingSerializer
- func (s *ValidatingSerializer[Model]) AddValidator(validator Validator) *ValidatingSerializer[Model]
- func (s *ValidatingSerializer[Model]) ToInternalValue(raw map[string]any, ctx *gin.Context) (models.InternalValue, error)
- func (s *ValidatingSerializer[Model]) ToRepresentation(intVal models.InternalValue, ctx *gin.Context) (Representation, error)
- type ValidationError
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TransformError ¶
TransformError recursively transforms a ValidationError into a map[string][]string.
Types ¶
type MissingSerializer ¶
type MissingSerializer[Model any] struct { }
func (*MissingSerializer[Model]) FromDB ¶
func (s *MissingSerializer[Model]) FromDB(raw map[string]any, ctx *gin.Context) (models.InternalValue, error)
func (*MissingSerializer[Model]) ToInternalValue ¶
func (s *MissingSerializer[Model]) ToInternalValue(raw map[string]any, ctx *gin.Context) (models.InternalValue, error)
func (*MissingSerializer[Model]) ToRepresentation ¶
func (s *MissingSerializer[Model]) ToRepresentation(intVal models.InternalValue, ctx *gin.Context) (Representation, error)
type ModelSerializer ¶
type ModelSerializer[Model any] struct { Fields map[string]*fields.Field[Model] // contains filtered or unexported fields }
func NewModelSerializer ¶
func NewModelSerializer[Model any]() *ModelSerializer[Model]
func (*ModelSerializer[Model]) ToInternalValue ¶
func (s *ModelSerializer[Model]) ToInternalValue(raw map[string]any, ctx *gin.Context) (models.InternalValue, error)
func (*ModelSerializer[Model]) ToRepresentation ¶
func (s *ModelSerializer[Model]) ToRepresentation(intVal models.InternalValue, ctx *gin.Context) (Representation, error)
func (*ModelSerializer[Model]) Validate ¶
func (s *ModelSerializer[Model]) Validate(intVal models.InternalValue, ctx *gin.Context) error
func (*ModelSerializer[Model]) WithField ¶
func (s *ModelSerializer[Model]) WithField(name string, updateFunc func(oldField *fields.Field[Model])) *ModelSerializer[Model]
func (*ModelSerializer[Model]) WithModelFields ¶
func (s *ModelSerializer[Model]) WithModelFields(passedFields []string) *ModelSerializer[Model]
func (*ModelSerializer[Model]) WithNewField ¶
func (s *ModelSerializer[Model]) WithNewField(field *fields.Field[Model]) *ModelSerializer[Model]
type Representation ¶
type Serializer ¶
type Serializer interface { ToInternalValue(map[string]any, *gin.Context) (models.InternalValue, error) ToRepresentation(models.InternalValue, *gin.Context) (Representation, error) }
type ValidatingSerializer ¶
type ValidatingSerializer[Model any] struct { // contains filtered or unexported fields }
func NewValidatingSerializer ¶
func NewValidatingSerializer[Model any](child Serializer, validator ...Validator) *ValidatingSerializer[Model]
func (*ValidatingSerializer[Model]) AddValidator ¶
func (s *ValidatingSerializer[Model]) AddValidator(validator Validator) *ValidatingSerializer[Model]
func (*ValidatingSerializer[Model]) ToInternalValue ¶
func (s *ValidatingSerializer[Model]) ToInternalValue(raw map[string]any, ctx *gin.Context) (models.InternalValue, error)
func (*ValidatingSerializer[Model]) ToRepresentation ¶
func (s *ValidatingSerializer[Model]) ToRepresentation(intVal models.InternalValue, ctx *gin.Context) (Representation, error)
type ValidationError ¶
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Uses string builder to build error message
type Validator ¶
type Validator interface {
Validate(models.InternalValue) error
}
func NewJSONSchemaValidator ¶
func NewSimpleValidator ¶
func NewSimpleValidator(validateFunc func(models.InternalValue) error) Validator
Click to show internal directories.
Click to hide internal directories.