3 Star 2 Fork 0

Gitee 极速下载/go-swagger

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/go-swagger/go-swagger
Clone or Download
validation_error.go 2.13 KB
Copy Edit Raw Blame History
fredbi authored 2018-07-04 23:04 +08:00 . regen examples
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
)
// ValidationError validation error
// swagger:model ValidationError
type ValidationError struct {
Error
// an optional field name to which this validation error applies
Field string `json:"field,omitempty"`
}
// UnmarshalJSON unmarshals this object from a JSON structure
func (m *ValidationError) UnmarshalJSON(raw []byte) error {
// AO0
var aO0 Error
if err := swag.ReadJSON(raw, &aO0); err != nil {
return err
}
m.Error = aO0
// AO1
var dataAO1 struct {
Field string `json:"field,omitempty"`
}
if err := swag.ReadJSON(raw, &dataAO1); err != nil {
return err
}
m.Field = dataAO1.Field
return nil
}
// MarshalJSON marshals this object to a JSON structure
func (m ValidationError) MarshalJSON() ([]byte, error) {
_parts := make([][]byte, 0, 2)
aO0, err := swag.WriteJSON(m.Error)
if err != nil {
return nil, err
}
_parts = append(_parts, aO0)
var dataAO1 struct {
Field string `json:"field,omitempty"`
}
dataAO1.Field = m.Field
jsonDataAO1, errAO1 := swag.WriteJSON(dataAO1)
if errAO1 != nil {
return nil, errAO1
}
_parts = append(_parts, jsonDataAO1)
return swag.ConcatJSON(_parts...), nil
}
// Validate validates this validation error
func (m *ValidationError) Validate(formats strfmt.Registry) error {
var res []error
// validation for a type composition with Error
if err := m.Error.Validate(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
// MarshalBinary interface implementation
func (m *ValidationError) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *ValidationError) UnmarshalBinary(b []byte) error {
var res ValidationError
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/mirrors/go-swagger.git
git@gitee.com:mirrors/go-swagger.git
mirrors
go-swagger
go-swagger
v0.19.0

Search