• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang goa.InvalidAttributeTypeError函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/raphael/goa.InvalidAttributeTypeError函数的典型用法代码示例。如果您正苦于以下问题:Golang InvalidAttributeTypeError函数的具体用法?Golang InvalidAttributeTypeError怎么用?Golang InvalidAttributeTypeError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了InvalidAttributeTypeError函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: UnmarshalRateBottlePayload

// UnmarshalRateBottlePayload unmarshals and validates a raw interface{} into an instance of RateBottlePayload
func UnmarshalRateBottlePayload(source interface{}, inErr error) (target *RateBottlePayload, err error) {
	err = inErr
	if val, ok := source.(map[string]interface{}); ok {
		target = new(RateBottlePayload)
		if v, ok := val["rating"]; ok {
			var tmp12 int
			if f, ok := v.(float64); ok {
				tmp12 = int(f)
			} else {
				err = goa.InvalidAttributeTypeError(`payload.Rating`, v, "int", err)
			}
			if err == nil {
				if tmp12 < 1 {
					err = goa.InvalidRangeError(`payload.Rating`, tmp12, 1, true, err)
				}
				if tmp12 > 5 {
					err = goa.InvalidRangeError(`payload.Rating`, tmp12, 5, false, err)
				}
			}
			target.Rating = tmp12
		} else {
			err = goa.MissingAttributeError(`payload`, "rating", err)
		}
	} else {
		err = goa.InvalidAttributeTypeError(`payload`, source, "dictionary", err)
	}
	return
}
开发者ID:cw2018,项目名称:goa,代码行数:29,代码来源:contexts.go


示例2: NewCreateSeriesPayload

// NewCreateSeriesPayload instantiates a CreateSeriesPayload from a raw request body.
// It validates each field and returns an error if any validation fails.
func NewCreateSeriesPayload(raw interface{}) (*CreateSeriesPayload, error) {
	var err error
	var p *CreateSeriesPayload
	if val, ok := raw.(map[string]interface{}); ok {
		p = new(CreateSeriesPayload)
		if v, ok := val["name"]; ok {
			var tmp3 string
			if val, ok := v.(string); ok {
				tmp3 = val
			} else {
				err = goa.InvalidAttributeTypeError(`payload.Name`, v, "string", err)
			}
			if err == nil {
				if len(tmp3) < 2 {
					err = goa.InvalidLengthError(`payload.Name`, tmp3, 2, true, err)
				}
			}
			p.Name = tmp3
		} else {
			err = goa.MissingAttributeError(`payload`, "name", err)
		}
	} else {
		err = goa.InvalidAttributeTypeError(`payload`, raw, "map[string]interface{}", err)
	}
	return p, err
}
开发者ID:AidHamza,项目名称:congo,代码行数:28,代码来源:contexts.go


示例3: NewRateBottlePayload

// NewRateBottlePayload instantiates a RateBottlePayload from a raw request body.
// It validates each field and returns an error if any validation fails.
func NewRateBottlePayload(raw interface{}) (*RateBottlePayload, error) {
	var err error
	var p *RateBottlePayload
	if val, ok := raw.(map[string]interface{}); ok {
		p = new(RateBottlePayload)
		if v, ok := val["rating"]; ok {
			var tmp12 int
			if f, ok := v.(float64); ok {
				tmp12 = int(f)
			} else {
				err = goa.InvalidAttributeTypeError(`payload.Rating`, v, "int", err)
			}
			if err == nil {
				if tmp12 < 1 {
					err = goa.InvalidRangeError(`payload.Rating`, tmp12, 1, true, err)
				}
				if tmp12 > 5 {
					err = goa.InvalidRangeError(`payload.Rating`, tmp12, 5, false, err)
				}
			}
			p.Rating = tmp12
		} else {
			err = goa.MissingAttributeError(`payload`, "rating", err)
		}
	} else {
		err = goa.InvalidAttributeTypeError(`payload`, raw, "map[string]interface{}", err)
	}
	return p, err
}
开发者ID:harboe,项目名称:goa,代码行数:31,代码来源:contexts.go


示例4: NewCreateUserPayload

// NewCreateUserPayload instantiates a CreateUserPayload from a raw request body.
// It validates each field and returns an error if any validation fails.
func NewCreateUserPayload(raw interface{}) (*CreateUserPayload, error) {
	var err error
	var p *CreateUserPayload
	if val, ok := raw.(map[string]interface{}); ok {
		p = new(CreateUserPayload)
		if v, ok := val["email"]; ok {
			var tmp5 string
			if val, ok := v.(string); ok {
				tmp5 = val
			} else {
				err = goa.InvalidAttributeTypeError(`payload.Email`, v, "string", err)
			}
			if err == nil {
				if len(tmp5) < 2 {
					err = goa.InvalidLengthError(`payload.Email`, tmp5, 2, true, err)
				}
			}
			p.Email = tmp5
		}
		if v, ok := val["first_name"]; ok {
			var tmp6 string
			if val, ok := v.(string); ok {
				tmp6 = val
			} else {
				err = goa.InvalidAttributeTypeError(`payload.FirstName`, v, "string", err)
			}
			if err == nil {
				if len(tmp6) < 2 {
					err = goa.InvalidLengthError(`payload.FirstName`, tmp6, 2, true, err)
				}
			}
			p.FirstName = tmp6
		} else {
			err = goa.MissingAttributeError(`payload`, "first_name", err)
		}
		if v, ok := val["last_name"]; ok {
			var tmp7 string
			if val, ok := v.(string); ok {
				tmp7 = val
			} else {
				err = goa.InvalidAttributeTypeError(`payload.LastName`, v, "string", err)
			}
			if err == nil {
				if len(tmp7) < 2 {
					err = goa.InvalidLengthError(`payload.LastName`, tmp7, 2, true, err)
				}
			}
			p.LastName = tmp7
		}
	} else {
		err = goa.InvalidAttributeTypeError(`payload`, raw, "map[string]interface{}", err)
	}
	return p, err
}
开发者ID:AidHamza,项目名称:congo,代码行数:56,代码来源:contexts.go


示例5: NewUpdateUserPayload

// NewUpdateUserPayload instantiates a UpdateUserPayload from a raw request body.
// It validates each field and returns an error if any validation fails.
func NewUpdateUserPayload(raw interface{}) (*UpdateUserPayload, error) {
	var err error
	var p *UpdateUserPayload
	if val, ok := raw.(map[string]interface{}); ok {
		p = new(UpdateUserPayload)
		if v, ok := val["email"]; ok {
			var tmp8 string
			if val, ok := v.(string); ok {
				tmp8 = val
			} else {
				err = goa.InvalidAttributeTypeError(`payload.Email`, v, "string", err)
			}
			if err == nil {
				if len(tmp8) < 2 {
					err = goa.InvalidLengthError(`payload.Email`, tmp8, 2, true, err)
				}
			}
			p.Email = tmp8
		}
		if v, ok := val["first_name"]; ok {
			var tmp9 string
			if val, ok := v.(string); ok {
				tmp9 = val
			} else {
				err = goa.InvalidAttributeTypeError(`payload.FirstName`, v, "string", err)
			}
			if err == nil {
				if len(tmp9) < 2 {
					err = goa.InvalidLengthError(`payload.FirstName`, tmp9, 2, true, err)
				}
			}
			p.FirstName = tmp9
		}
		if v, ok := val["last_name"]; ok {
			var tmp10 string
			if val, ok := v.(string); ok {
				tmp10 = val
			} else {
				err = goa.InvalidAttributeTypeError(`payload.LastName`, v, "string", err)
			}
			if err == nil {
				if len(tmp10) < 2 {
					err = goa.InvalidLengthError(`payload.LastName`, tmp10, 2, true, err)
				}
			}
			p.LastName = tmp10
		}
	} else {
		err = goa.InvalidAttributeTypeError(`payload`, raw, "map[string]interface{}", err)
	}
	return p, err
}
开发者ID:AidHamza,项目名称:congo,代码行数:54,代码来源:contexts.go


示例6: UnmarshalCreateAccountPayload

// UnmarshalCreateAccountPayload unmarshals and validates a raw interface{} into an instance of CreateAccountPayload
func UnmarshalCreateAccountPayload(source interface{}, inErr error) (target *CreateAccountPayload, err error) {
	err = inErr
	if val, ok := source.(map[string]interface{}); ok {
		target = new(CreateAccountPayload)
		if v, ok := val["name"]; ok {
			var tmp1 string
			if val, ok := v.(string); ok {
				tmp1 = val
			} else {
				err = goa.InvalidAttributeTypeError(`payload.Name`, v, "string", err)
			}
			target.Name = tmp1
		} else {
			err = goa.MissingAttributeError(`payload`, "name", err)
		}
	} else {
		err = goa.InvalidAttributeTypeError(`payload`, source, "dictionary", err)
	}
	return
}
开发者ID:cw2018,项目名称:goa,代码行数:21,代码来源:contexts.go


示例7: NewCreateAccountPayload

// NewCreateAccountPayload instantiates a CreateAccountPayload from a raw request body.
// It validates each field and returns an error if any validation fails.
func NewCreateAccountPayload(raw interface{}) (*CreateAccountPayload, error) {
	var err error
	var p *CreateAccountPayload
	if val, ok := raw.(map[string]interface{}); ok {
		p = new(CreateAccountPayload)
		if v, ok := val["name"]; ok {
			var tmp1 string
			if val, ok := v.(string); ok {
				tmp1 = val
			} else {
				err = goa.InvalidAttributeTypeError(`payload.Name`, v, "string", err)
			}
			p.Name = tmp1
		} else {
			err = goa.MissingAttributeError(`payload`, "name", err)
		}
	} else {
		err = goa.InvalidAttributeTypeError(`payload`, raw, "map[string]interface{}", err)
	}
	return p, err
}
开发者ID:harboe,项目名称:goa,代码行数:23,代码来源:contexts.go


示例8: UnmarshalBottleCollection

// UnmarshalBottleCollection unmarshals and validates a raw interface{} into an instance of BottleCollection
func UnmarshalBottleCollection(source interface{}, inErr error) (target BottleCollection, err error) {
	err = inErr
	if val, ok := source.([]interface{}); ok {
		target = make([]*Bottle, len(val))
		for tmp51, v := range val {
			target[tmp51], err = UnmarshalBottle(v, err)
		}
	} else {
		err = goa.InvalidAttributeTypeError(`load`, source, "array", err)
	}
	return
}
开发者ID:tylerb,项目名称:goa,代码行数:13,代码来源:media_types.go


示例9: LoadBottle

// LoadBottle loads raw data into an instance of Bottle running all the
// validations. Raw data is defined by data that the JSON unmarshaler would create when unmarshaling
// into a variable of type interface{}. See https://golang.org/pkg/encoding/json/#Unmarshal for the
// complete list of supported data types.
func LoadBottle(raw interface{}) (*Bottle, error) {
	var err error
	var res *Bottle
	if val, ok := raw.(map[string]interface{}); ok {
		res = new(Bottle)
		if v, ok := val["account"]; ok {
			var tmp29 *Account
			if val, ok := v.(map[string]interface{}); ok {
				tmp29 = new(Account)
				if v, ok := val["created_at"]; ok {
					var tmp30 string
					if val, ok := v.(string); ok {
						tmp30 = val
					} else {
						err = goa.InvalidAttributeTypeError(`.Account.CreatedAt`, v, "string", err)
					}
					if err == nil {
						if tmp30 != "" {
							if err2 := goa.ValidateFormat(goa.FormatDateTime, tmp30); err2 != nil {
								err = goa.InvalidFormatError(`.Account.CreatedAt`, tmp30, goa.FormatDateTime, err2, err)
							}
						}
					}
					tmp29.CreatedAt = tmp30
				}
				if v, ok := val["created_by"]; ok {
					var tmp31 string
					if val, ok := v.(string); ok {
						tmp31 = val
					} else {
						err = goa.InvalidAttributeTypeError(`.Account.CreatedBy`, v, "string", err)
					}
					if err == nil {
						if tmp31 != "" {
							if err2 := goa.ValidateFormat(goa.FormatEmail, tmp31); err2 != nil {
								err = goa.InvalidFormatError(`.Account.CreatedBy`, tmp31, goa.FormatEmail, err2, err)
							}
						}
					}
					tmp29.CreatedBy = tmp31
				}
				if v, ok := val["href"]; ok {
					var tmp32 string
					if val, ok := v.(string); ok {
						tmp32 = val
					} else {
						err = goa.InvalidAttributeTypeError(`.Account.Href`, v, "string", err)
					}
					tmp29.Href = tmp32
				}
				if v, ok := val["id"]; ok {
					var tmp33 int
					if f, ok := v.(float64); ok {
						tmp33 = int(f)
					} else {
						err = goa.InvalidAttributeTypeError(`.Account.ID`, v, "int", err)
					}
					tmp29.ID = tmp33
				}
				if v, ok := val["name"]; ok {
					var tmp34 string
					if val, ok := v.(string); ok {
						tmp34 = val
					} else {
						err = goa.InvalidAttributeTypeError(`.Account.Name`, v, "string", err)
					}
					tmp29.Name = tmp34
				}
			} else {
				err = goa.InvalidAttributeTypeError(`.Account`, v, "map[string]interface{}", err)
			}
			res.Account = tmp29
		}
		if v, ok := val["color"]; ok {
			var tmp35 string
			if val, ok := v.(string); ok {
				tmp35 = val
			} else {
				err = goa.InvalidAttributeTypeError(`.Color`, v, "string", err)
			}
			if err == nil {
				if tmp35 != "" {
					if !(tmp35 == "red" || tmp35 == "white" || tmp35 == "rose" || tmp35 == "yellow" || tmp35 == "sparkling") {
						err = goa.InvalidEnumValueError(`.Color`, tmp35, []interface{}{"red", "white", "rose", "yellow", "sparkling"}, err)
					}
				}
			}
			res.Color = tmp35
		}
		if v, ok := val["country"]; ok {
			var tmp36 string
			if val, ok := v.(string); ok {
				tmp36 = val
			} else {
				err = goa.InvalidAttributeTypeError(`.Country`, v, "string", err)
			}
//.........这里部分代码省略.........
开发者ID:harboe,项目名称:goa,代码行数:101,代码来源:media_types.go


示例10:

		})
	})
})

var _ = Describe("InvalidAttributeTypeError", func() {
	var valErr, err error
	ctx := "ctx"
	val := 42
	expected := "43"

	BeforeEach(func() {
		err = nil
	})

	JustBeforeEach(func() {
		valErr = goa.InvalidAttributeTypeError(ctx, val, expected, err)
	})

	It("creates a multi error", func() {
		Ω(valErr).ShouldNot(BeNil())
		Ω(valErr).Should(BeAssignableToTypeOf(goa.MultiError{}))
		mErr := valErr.(goa.MultiError)
		Ω(mErr).Should(HaveLen(1))
		Ω(mErr[0]).Should(BeAssignableToTypeOf(&goa.TypedError{}))
		tErr := mErr[0].(*goa.TypedError)
		Ω(tErr.ID).Should(Equal(goa.ErrorID((goa.ErrInvalidAttributeType))))
		Ω(tErr.Mesg).Should(ContainSubstring(ctx))
		Ω(tErr.Mesg).Should(ContainSubstring("%d", val))
		Ω(tErr.Mesg).Should(ContainSubstring(expected))
	})
开发者ID:harboe,项目名称:goa,代码行数:30,代码来源:error_test.go


示例11: LoadUserCollection

// LoadUserCollection loads raw data into an instance of UserCollection running all the
// validations. Raw data is defined by data that the JSON unmarshaler would create when unmarshaling
// into a variable of type interface{}. See https://golang.org/pkg/encoding/json/#Unmarshal for the
// complete list of supported data types.
func LoadUserCollection(raw interface{}) (UserCollection, error) {
	var err error
	var res UserCollection
	if val, ok := raw.([]interface{}); ok {
		res = make([]*User, len(val))
		for i, v := range val {
			var tmp62 *User
			if val, ok := v.(map[string]interface{}); ok {
				tmp62 = new(User)
				if v, ok := val["created_at"]; ok {
					var tmp63 string
					if val, ok := v.(string); ok {
						tmp63 = val
					} else {
						err = goa.InvalidAttributeTypeError(`[*].CreatedAt`, v, "string", err)
					}
					if err == nil {
						if tmp63 != "" {
							if err2 := goa.ValidateFormat(goa.FormatDateTime, tmp63); err2 != nil {
								err = goa.InvalidFormatError(`[*].CreatedAt`, tmp63, goa.FormatDateTime, err2, err)
							}
						}
					}
					tmp62.CreatedAt = tmp63
				}
				if v, ok := val["email"]; ok {
					var tmp64 string
					if val, ok := v.(string); ok {
						tmp64 = val
					} else {
						err = goa.InvalidAttributeTypeError(`[*].Email`, v, "string", err)
					}
					if err == nil {
						if tmp64 != "" {
							if err2 := goa.ValidateFormat(goa.FormatEmail, tmp64); err2 != nil {
								err = goa.InvalidFormatError(`[*].Email`, tmp64, goa.FormatEmail, err2, err)
							}
						}
					}
					tmp62.Email = tmp64
				}
				if v, ok := val["first_name"]; ok {
					var tmp65 string
					if val, ok := v.(string); ok {
						tmp65 = val
					} else {
						err = goa.InvalidAttributeTypeError(`[*].FirstName`, v, "string", err)
					}
					tmp62.FirstName = tmp65
				}
				if v, ok := val["href"]; ok {
					var tmp66 string
					if val, ok := v.(string); ok {
						tmp66 = val
					} else {
						err = goa.InvalidAttributeTypeError(`[*].Href`, v, "string", err)
					}
					tmp62.Href = tmp66
				}
				if v, ok := val["id"]; ok {
					var tmp67 int
					if f, ok := v.(float64); ok {
						tmp67 = int(f)
					} else {
						err = goa.InvalidAttributeTypeError(`[*].ID`, v, "int", err)
					}
					tmp62.ID = tmp67
				}
				if v, ok := val["last_name"]; ok {
					var tmp68 string
					if val, ok := v.(string); ok {
						tmp68 = val
					} else {
						err = goa.InvalidAttributeTypeError(`[*].LastName`, v, "string", err)
					}
					tmp62.LastName = tmp68
				}
			} else {
				err = goa.InvalidAttributeTypeError(`[*]`, v, "map[string]interface{}", err)
			}
			res[i] = tmp62
		}
	} else {
		err = goa.InvalidAttributeTypeError(``, raw, "[]interface{}", err)
	}
	return res, err
}
开发者ID:AidHamza,项目名称:congo,代码行数:91,代码来源:media_types.go


示例12: LoadUser

// LoadUser loads raw data into an instance of User running all the
// validations. Raw data is defined by data that the JSON unmarshaler would create when unmarshaling
// into a variable of type interface{}. See https://golang.org/pkg/encoding/json/#Unmarshal for the
// complete list of supported data types.
func LoadUser(raw interface{}) (*User, error) {
	var err error
	var res *User
	if val, ok := raw.(map[string]interface{}); ok {
		res = new(User)
		if v, ok := val["created_at"]; ok {
			var tmp54 string
			if val, ok := v.(string); ok {
				tmp54 = val
			} else {
				err = goa.InvalidAttributeTypeError(`.CreatedAt`, v, "string", err)
			}
			if err == nil {
				if tmp54 != "" {
					if err2 := goa.ValidateFormat(goa.FormatDateTime, tmp54); err2 != nil {
						err = goa.InvalidFormatError(`.CreatedAt`, tmp54, goa.FormatDateTime, err2, err)
					}
				}
			}
			res.CreatedAt = tmp54
		}
		if v, ok := val["email"]; ok {
			var tmp55 string
			if val, ok := v.(string); ok {
				tmp55 = val
			} else {
				err = goa.InvalidAttributeTypeError(`.Email`, v, "string", err)
			}
			if err == nil {
				if tmp55 != "" {
					if err2 := goa.ValidateFormat(goa.FormatEmail, tmp55); err2 != nil {
						err = goa.InvalidFormatError(`.Email`, tmp55, goa.FormatEmail, err2, err)
					}
				}
			}
			res.Email = tmp55
		}
		if v, ok := val["first_name"]; ok {
			var tmp56 string
			if val, ok := v.(string); ok {
				tmp56 = val
			} else {
				err = goa.InvalidAttributeTypeError(`.FirstName`, v, "string", err)
			}
			res.FirstName = tmp56
		}
		if v, ok := val["href"]; ok {
			var tmp57 string
			if val, ok := v.(string); ok {
				tmp57 = val
			} else {
				err = goa.InvalidAttributeTypeError(`.Href`, v, "string", err)
			}
			res.Href = tmp57
		}
		if v, ok := val["id"]; ok {
			var tmp58 int
			if f, ok := v.(float64); ok {
				tmp58 = int(f)
			} else {
				err = goa.InvalidAttributeTypeError(`.ID`, v, "int", err)
			}
			res.ID = tmp58
		}
		if v, ok := val["last_name"]; ok {
			var tmp59 string
			if val, ok := v.(string); ok {
				tmp59 = val
			} else {
				err = goa.InvalidAttributeTypeError(`.LastName`, v, "string", err)
			}
			res.LastName = tmp59
		}
	} else {
		err = goa.InvalidAttributeTypeError(``, raw, "map[string]interface{}", err)
	}
	return res, err
}
开发者ID:AidHamza,项目名称:congo,代码行数:82,代码来源:media_types.go


示例13: LoadSeriesCollection

// LoadSeriesCollection loads raw data into an instance of SeriesCollection running all the
// validations. Raw data is defined by data that the JSON unmarshaler would create when unmarshaling
// into a variable of type interface{}. See https://golang.org/pkg/encoding/json/#Unmarshal for the
// complete list of supported data types.
func LoadSeriesCollection(raw interface{}) (SeriesCollection, error) {
	var err error
	var res SeriesCollection
	if val, ok := raw.([]interface{}); ok {
		res = make([]*Series, len(val))
		for i, v := range val {
			var tmp36 *Series
			if val, ok := v.(map[string]interface{}); ok {
				tmp36 = new(Series)
				if v, ok := val["account"]; ok {
					var tmp37 *Account
					if val, ok := v.(map[string]interface{}); ok {
						tmp37 = new(Account)
						if v, ok := val["created_at"]; ok {
							var tmp38 string
							if val, ok := v.(string); ok {
								tmp38 = val
							} else {
								err = goa.InvalidAttributeTypeError(`[*].Account.CreatedAt`, v, "string", err)
							}
							if err == nil {
								if tmp38 != "" {
									if err2 := goa.ValidateFormat(goa.FormatDateTime, tmp38); err2 != nil {
										err = goa.InvalidFormatError(`[*].Account.CreatedAt`, tmp38, goa.FormatDateTime, err2, err)
									}
								}
							}
							tmp37.CreatedAt = tmp38
						}
						if v, ok := val["created_by"]; ok {
							var tmp39 string
							if val, ok := v.(string); ok {
								tmp39 = val
							} else {
								err = goa.InvalidAttributeTypeError(`[*].Account.CreatedBy`, v, "string", err)
							}
							if err == nil {
								if tmp39 != "" {
									if err2 := goa.ValidateFormat(goa.FormatEmail, tmp39); err2 != nil {
										err = goa.InvalidFormatError(`[*].Account.CreatedBy`, tmp39, goa.FormatEmail, err2, err)
									}
								}
							}
							tmp37.CreatedBy = tmp39
						}
						if v, ok := val["href"]; ok {
							var tmp40 string
							if val, ok := v.(string); ok {
								tmp40 = val
							} else {
								err = goa.InvalidAttributeTypeError(`[*].Account.Href`, v, "string", err)
							}
							tmp37.Href = tmp40
						}
						if v, ok := val["id"]; ok {
							var tmp41 int
							if f, ok := v.(float64); ok {
								tmp41 = int(f)
							} else {
								err = goa.InvalidAttributeTypeError(`[*].Account.ID`, v, "int", err)
							}
							tmp37.ID = tmp41
						}
						if v, ok := val["name"]; ok {
							var tmp42 string
							if val, ok := v.(string); ok {
								tmp42 = val
							} else {
								err = goa.InvalidAttributeTypeError(`[*].Account.Name`, v, "string", err)
							}
							tmp37.Name = tmp42
						}
					} else {
						err = goa.InvalidAttributeTypeError(`[*].Account`, v, "map[string]interface{}", err)
					}
					tmp36.Account = tmp37
				}
				if v, ok := val["created_at"]; ok {
					var tmp43 string
					if val, ok := v.(string); ok {
						tmp43 = val
					} else {
						err = goa.InvalidAttributeTypeError(`[*].CreatedAt`, v, "string", err)
					}
					if err == nil {
						if tmp43 != "" {
							if err2 := goa.ValidateFormat(goa.FormatDateTime, tmp43); err2 != nil {
								err = goa.InvalidFormatError(`[*].CreatedAt`, tmp43, goa.FormatDateTime, err2, err)
							}
						}
					}
					tmp36.CreatedAt = tmp43
				}
				if v, ok := val["href"]; ok {
					var tmp44 string
					if val, ok := v.(string); ok {
//.........这里部分代码省略.........
开发者ID:AidHamza,项目名称:congo,代码行数:101,代码来源:media_types.go


示例14: LoadSeries

// LoadSeries loads raw data into an instance of Series running all the
// validations. Raw data is defined by data that the JSON unmarshaler would create when unmarshaling
// into a variable of type interface{}. See https://golang.org/pkg/encoding/json/#Unmarshal for the
// complete list of supported data types.
func LoadSeries(raw interface{}) (*Series, error) {
	var err error
	var res *Series
	if val, ok := raw.(map[string]interface{}); ok {
		res = new(Series)
		if v, ok := val["account"]; ok {
			var tmp18 *Account
			if val, ok := v.(map[string]interface{}); ok {
				tmp18 = new(Account)
				if v, ok := val["created_at"]; ok {
					var tmp19 string
					if val, ok := v.(string); ok {
						tmp19 = val
					} else {
						err = goa.InvalidAttributeTypeError(`.Account.CreatedAt`, v, "string", err)
					}
					if err == nil {
						if tmp19 != "" {
							if err2 := goa.ValidateFormat(goa.FormatDateTime, tmp19); err2 != nil {
								err = goa.InvalidFormatError(`.Account.CreatedAt`, tmp19, goa.FormatDateTime, err2, err)
							}
						}
					}
					tmp18.CreatedAt = tmp19
				}
				if v, ok := val["created_by"]; ok {
					var tmp20 string
					if val, ok := v.(string); ok {
						tmp20 = val
					} else {
						err = goa.InvalidAttributeTypeError(`.Account.CreatedBy`, v, "string", err)
					}
					if err == nil {
						if tmp20 != "" {
							if err2 := goa.ValidateFormat(goa.FormatEmail, tmp20); err2 != nil {
								err = goa.InvalidFormatError(`.Account.CreatedBy`, tmp20, goa.FormatEmail, err2, err)
							}
						}
					}
					tmp18.CreatedBy = tmp20
				}
				if v, ok := val["href"]; ok {
					var tmp21 string
					if val, ok := v.(string); ok {
						tmp21 = val
					} else {
						err = goa.InvalidAttributeTypeError(`.Account.Href`, v, "string", err)
					}
					tmp18.Href = tmp21
				}
				if v, ok := val["id"]; ok {
					var tmp22 int
					if f, ok := v.(float64); ok {
						tmp22 = int(f)
					} else {
						err = goa.InvalidAttributeTypeError(`.Account.ID`, v, "int", err)
					}
					tmp18.ID = tmp22
				}
				if v, ok := val["name"]; ok {
					var tmp23 string
					if val, ok := v.(string); ok {
						tmp23 = val
					} else {
						err = goa.InvalidAttributeTypeError(`.Account.Name`, v, "string", err)
					}
					tmp18.Name = tmp23
				}
			} else {
				err = goa.InvalidAttributeTypeError(`.Account`, v, "map[string]interface{}", err)
			}
			res.Account = tmp18
		}
		if v, ok := val["created_at"]; ok {
			var tmp24 string
			if val, ok := v.(string); ok {
				tmp24 = val
			} else {
				err = goa.InvalidAttributeTypeError(`.CreatedAt`, v, "string", err)
			}
			if err == nil {
				if tmp24 != "" {
					if err2 := goa.ValidateFormat(goa.FormatDateTime, tmp24); err2 != nil {
						err = goa.InvalidFormatError(`.CreatedAt`, tmp24, goa.FormatDateTime, err2, err)
					}
				}
			}
			res.CreatedAt = tmp24
		}
		if v, ok := val["href"]; ok {
			var tmp25 string
			if val, ok := v.(string); ok {
				tmp25 = val
			} else {
				err = goa.InvalidAttributeTypeError(`.Href`, v, "string", err)
			}
//.........这里部分代码省略.........
开发者ID:AidHamza,项目名称:congo,代码行数:101,代码来源:media_types.go


示例15: UnmarshalAccount

// UnmarshalAccount unmarshals and validates a raw interface{} into an instance of Account
func UnmarshalAccount(source interface{}, inErr error) (target *Account, err error) {
	err = inErr
	if val, ok := source.(map[string]interface{}); ok {
		target = new(Account)
		if v, ok := val["created_at"]; ok {
			var tmp24 string
			if val, ok := v.(string); ok {
				tmp24 = val
			} else {
				err = goa.InvalidAttributeTypeError(`load.CreatedAt`, v, "string", err)
			}
			if err == nil {
				if tmp24 != "" {
					if err2 := goa.ValidateFormat(goa.FormatDateTime, tmp24); err2 != nil {
						err = goa.InvalidFormatError(`load.CreatedAt`, tmp24, goa.FormatDateTime, err2, err)
					}
				}
			}
			target.CreatedAt = tmp24
		}
		if v, ok := val["created_by"]; ok {
			var tmp25 string
			if val, ok := v.(string); ok {
				tmp25 = val
			} else {
				err = goa.InvalidAttributeTypeError(`load.CreatedBy`, v, "string", err)
			}
			if err == nil {
				if tmp25 != "" {
					if err2 := goa.ValidateFormat(goa.FormatEmail, tmp25); err2 != nil {
						err = goa.InvalidFormatError(`load.CreatedBy`, tmp25, goa.FormatEmail, err2, err)
					}
				}
			}
			target.CreatedBy = tmp25
		}
		if v, ok := val["href"]; ok {
			var tmp26 string
			if val, ok := v.(string); ok {
				tmp26 = val
			} else {
				err = goa.InvalidAttributeTypeError(`load.Href`, v, "string", err)
			}
			target.Href = tmp26
		}
		if v, ok := val["id"]; ok {
			var tmp27 int
			if f, ok := v.(float64); ok {
				tmp27 = int(f)
			} else {
				err = goa.InvalidAttributeTypeError(`load.ID`, v, "int", err)
			}
			target.ID = tmp27
		}
		if v, ok := val["name"]; ok {
			var tmp28 string
			if val, ok := v.(string); ok {
				tmp28 = val
			} else {
				err = goa.InvalidAttributeTypeError(`load.Name`, v, "string", err)
			}
			target.Name = tmp28
		}
	} else {
		err = goa.InvalidAttributeTypeError(`load`, source, "dictionary", err)
	}
	return
}
开发者ID:tylerb,项目名称:goa,代码行数:69,代码来源:media_types.go


示例16: UnmarshalCreateBottlePayload

// UnmarshalCreateBottlePayload unmarshals and validates a raw interface{} into an instance of CreateBottlePayload
func UnmarshalCreateBottlePayload(source interface{}, inErr error) (target *CreateBottlePayload, err error) {
	err = inErr
	if val, ok := source.(map[string]interface{}); ok {
		target = new(CreateBottlePayload)
		if v, ok := val["color"]; ok {
			var tmp3 string
			if val, ok := v.(string); ok {
				tmp3 = val
			} else {
				err = goa.InvalidAttributeTypeError(`payload.Color`, v, "string", err)
			}
			if err == nil {
				if tmp3 != "" {
					if !(tmp3 == "red" || tmp3 == "white" || tmp3 == "rose" || tmp3 == "yellow" || tmp3 == "sparkling") {
						err = goa.InvalidEnumValueError(`payload.Color`, tmp3, []interface{}{"red", "white", "rose", "yellow", "sparkling"}, err)
					}
				}
			}
			target.Color = tmp3
		} else {
			err = goa.MissingAttributeError(`payload`, "color", err)
		}
		if v, ok := val["country"]; ok {
			var tmp4 string
			if val, ok := v.(string); ok {
				tmp4 = val
			} else {
				err = goa.InvalidAttributeTypeError(`payload.Country`, v, "string", err)
			}
			if err == nil {
				if len(tmp4) < 2 {
					err = goa.InvalidLengthError(`payload.Country`, tmp4, len(tmp4), 2, true, err)
				}
			}
			target.Country = tmp4
		}
		if v, ok := val["name"]; ok {
			var tmp5 string
			if val, ok := v.(string); ok {
				tmp5 = val
			} else {
				err = goa.InvalidAttributeTypeError(`payload.Name`, v, "string", err)
			}
			if err == nil {
				if len(tmp5) < 2 {
					err = goa.InvalidLengthError(`payload.Name`, tmp5, len(tmp5), 2, true, err)
				}
			}
			target.Name = tmp5
		} else {
			err = goa.MissingAttributeError(`payload`, "name", err)
		}
		if v, ok := val["region"]; ok {
			var tmp6 string
			if val, ok := v.(string); ok {
				tmp6 = val
			} else {
				err = goa.InvalidAttributeTypeError(`payload.Region`, v, "string", err)
			}
			target.Region = tmp6
		}
		if v, ok := val["review"]; ok {
			var tmp7 string
			if val, ok := v.(string); ok {
				tmp7 = val
			} else {
				err = goa.InvalidAttributeTypeError(`payload.Review`, v, "string", err)
			}
			if err == nil {
				if len(tmp7) < 10 {
					err = goa.InvalidLengthError(`payload.Review`, tmp7, len(tmp7), 10, true, err)
				}
				if len(tmp7) > 300 {
					err = goa.InvalidLengthError(`payload.Review`, tmp7, len(tmp7), 300, false, err)
				}
			}
			target.Review = tmp7
		}
		if v, ok := val["sweetness"]; ok {
			var tmp8 int
			if f, ok := v.(float64); ok {
				tmp8 = int(f)
			} else {
				err = goa.InvalidAttributeTypeError(`payload.Sweetness`, v, "int", err)
			}
			if err == nil {
				if tmp8 < 1 {
					err = goa.InvalidRangeError(`payload.Sweetness`, tmp8, 1, true, err)
				}
				if tmp8 > 5 {
					err = goa.InvalidRangeError(`payload.Sweetness`, tmp8, 5, false, err)
				}
			}
			target.Sweetness = tmp8
		}
		if v, ok := val["varietal"]; ok {
			var tmp9 string
			if val, ok := v.(string); ok {
				tmp9 = val
//.........这里部分代码省略.........
开发者ID:cw2018,项目名称:goa,代码行数:101,代码来源:contexts.go


示例17: UnmarshalBottle

// UnmarshalBottle unmarshals and validates a raw interface{} into an instance of Bottle
func UnmarshalBottle(source interface{}, inErr error) (target *Bottle, err error) {
	err = inErr
	if val, ok := source.(map[string]interface{}); ok {
		target = new(Bottle)
		if v, ok := val["account"]; ok {
			var tmp32 *Account
			tmp32, err = UnmarshalAccount(v, err)
			target.Account = tmp32
		}
		if v, ok := val["color"]; ok {
			var tmp33 string
			if val, ok := v.(string); ok {
				tmp33 = val
			} else {
				err = goa.InvalidAttributeTypeError(`load.Color`, v, "string", err)
			}
			if err == nil {
				if tmp33 != "" {
					if !(tmp33 == "red" || tmp33 == "white" || tmp33 == "rose" || tmp33 == "yellow" || tmp33 == "sparkling") {
						err = goa.InvalidEnumValueError(`load.Color`, tmp33, []interface{}{"red", "white", "rose", "yellow", "sparkling"}, err)
					}
				}
			}
			target.Color = tmp33
		}
		if v, ok := val["country"]; ok {
			var tmp34 string
			if val, ok := v.(string); ok {
				tmp34 = val
			} else {
				err = goa.InvalidAttributeTypeError(`load.Country`, v, "string", err)
			}
			if err == nil {
				if len(tmp34) < 2 {
					err = goa.InvalidLengthError(`load.Country`, tmp34, len(tmp34), 2, true, err)
				}
			}
			target.Country = tmp34
		}
		if v, ok := val["created_at"]; ok {
			var tmp35 string
			if val, ok := v.(string); ok {
				tmp35 = val
			} else {
				err = goa.InvalidAttributeTypeError(`load.CreatedAt`, v, "string", err)
			}
			if err == nil {
				if tmp35 != "" {
					if err2 := goa.ValidateFormat(goa.FormatDateTime, tmp35); err2 != nil {
						err = goa.InvalidFormatError(`load.CreatedAt`, tmp35, goa.FormatDateTime, err2, err)
					}
				}
			}
			target.CreatedAt = tmp35
		}
		if v, ok := val["href"]; ok {
			var tmp36 string
			if val, ok := v.(string); ok {
				tmp36 = val
			} else {
				err = goa.InvalidAttributeTypeError(`load.Href`, v, "string", err)
			}
			target.Href = tmp36
		}
		if v, ok := val["id"]; ok {
			var tmp37 int
			if f, ok := v.(float64); ok {
				tmp37 = int(f)
			} else {
				err = goa.InvalidAttributeTypeError(`load.ID`, v, "int", err)
			}
			target.ID = tmp37
		}
		if v, ok := val["name"]; ok {
			var tmp38 string
			if val, ok := v.(string); ok {
				tmp38 = val
			} else {
				err = goa.InvalidAttributeTypeError(`load.Name`, v, "string", err)
			}
			if err == nil {
				if len(tmp38) < 2 {
					err = goa.InvalidLengthError(`load.Name`, tmp38, len(tmp38), 2, true, err)
				}
			}
			target.Name = tmp38
		}
		if v, ok := val["rating"]; ok {
			var tmp39 int
			if f, ok := v.(float64); ok {
				tmp39 = int(f)
			} else {
				err = goa.InvalidAttributeTypeError(`load.Rating`, v, "int", err)
			}
			if err == nil {
				if tmp39 < 1 {
					err = goa.InvalidRangeError(`load.Rating`, tmp39, 1, true, err)
				}
				if tmp39 > 5 {
//.........这里部分代码省略.........
开发者ID:tylerb,项目名称:goa,代码行数:101,代码来源:media_types.go


示例18: LoadAccount

// LoadAccount loads raw data into an instance of Account running all the
// validations. Raw data is defined by data that the JSON unmarshaler would create when unmarshaling
// into a variable of type interface{}. See https://golang.org/pkg/encoding/json/#Unmarshal for the
// complete list of supported data types.
func LoadAccount(raw interface{}) (*Account, error) {
	var err error
	var res *Account
	if val, ok := raw.(map[string]interface{}); ok {
		res = new(Account)
		if v, ok := val["created_at"]; ok {
			var tmp22 string
			if val, ok := v.(string); ok {
				tmp22 = val
			} else {
				err = goa.InvalidAttributeTypeError(`.CreatedAt`, v, "string", err)
			}
			if err == nil {
				if tmp22 != "" {
					if err2 := goa.ValidateFormat(goa.FormatDateTime, tmp22); err2 != nil {
						err = goa.InvalidFormatError(`.CreatedAt`, tmp22, goa.FormatDateTime, err2, err)
					}
				}
			}
			res.CreatedAt = tmp22
		}
		if v, ok := val["created_by"]; ok {
			var tmp23 string
			if val, ok := v.(string); ok {
				tmp23 = val
			} else {
				err = goa.InvalidAttributeTypeError(`.CreatedBy`, v, "string", err)
			}
			if err == nil {
				if tmp23 != "" {
					if err2 := goa.ValidateFormat(goa.FormatEmail, tmp23); err2 != nil {
						err = goa.InvalidFormatError(`.CreatedBy`, tmp23, goa.FormatEmail, err2, err)
					}
				}
			}
			res.CreatedBy = tmp23
		}
		if v, ok := val["href"]; ok {
			var tmp24 string
			if val, ok := v.(string); ok {
				tmp24 = val
			} else {
				err = goa.InvalidAttributeTypeError(`.Href`, v, "string", err)
			}
			res.Href = tmp24
		}
		if v, ok := val["id"]; ok {
			var tmp25 int
			if f, ok := v.(float64); ok {
				tmp25 = int(f)
			} else {
				err = goa.InvalidAttributeTypeError(`.ID`, v, "int", err)
			}
			res.ID = tmp25
		}
		if v, ok := val["name"]; ok {
			var tmp26 string
			if val, ok := v.(string); ok {
				tmp26 = val
			} else {
				err = goa.InvalidAttributeTypeError(`.Name`, v, "string", err)
			}
			res.Name = tmp26
		}
	} else {
		err = goa.InvalidAttributeTypeError(``, raw, "map[string]interface{}", err)
	}
	return res, err
}
开发者ID:harboe,项目名称:goa,代码行数:73,代码来源:media_types.go


示例19: LoadBottleCollection

// LoadBottleCollection loads raw data into an instance of BottleCollection running all the
// validations. Raw data is defined by data that the JSON unmarshaler would create when unmarshaling
// into a variable of type interface{}. See https://golang.org/pkg/encoding/json/#Unmarshal for the
// complete list of supported data types.
func LoadBottleCollection(raw interface{}) (BottleCollection, error) {
	var err error
	var res BottleCollection
	if val, ok := raw.([]interface{}); ok {
		res = make([]*Bottle, len(val))
		for i, v := range val {
			var tmp56 *Bottle
			if val, ok := v.(map[string]interface{}); ok {
				tmp56 = new(Bottle)
				if v, ok := val["account"]; ok {
					var tmp57 *Account
					if val, ok := v.(map[string]interface{}); ok {
						tmp57 = new(Account)
						if v, ok := val["created_at"]; ok {
							var tmp58 string
							if val, ok := v.(string); ok {
								tmp58 = val
							} else {
								err = goa.InvalidAttributeTypeError(`[*].Account.CreatedAt`, v, "string", err)
							}
							if err == nil {
								if tmp58 != "" {
									if err2 := goa.ValidateFormat(goa.FormatDateTime, tmp58); err2 != nil {
										err = goa.InvalidFormatError(`[*].Account.CreatedAt`, tmp58, goa.FormatDateTime, err2, err)
									}
								}
							}
							tmp57.CreatedAt = tmp58
						}
						if v, ok := val["created_by"]; ok {
							var tmp59 string
							if val, ok := v.(string); ok {
								tmp59 = val
							} else {
								err = goa.InvalidAttributeTypeError(`[*].Account.CreatedBy`, v, "string", err)
							}
							if err == nil {
								if tmp59 != "" {
									if err2 := goa.ValidateFormat(goa.FormatEmail, tmp59); err2 != nil {
										err = goa.InvalidFormatError(`[*].Account.CreatedBy`, tmp59, goa.FormatEmail, err2, err)
									}
								}
							}
							tmp57.CreatedBy = tmp59
						}
						if v, ok := val["href"]; ok {
							var tmp60 string
							if val, ok := v.(string); ok {
								tmp60 = val
							} else {
								err = goa.InvalidAttributeTypeError(`[*].Account.Href`, v, "string", err)
							}
							tmp57.Href = tmp60
						}
						if v, ok := val["id"]; ok {
							var tmp61 int
							if f, ok := v.(float64); ok {
								tmp61 = int(f)
							} else {
								err = goa.InvalidAttributeTypeError(`[*].Account.ID`, v, "int", err)
							}
							tmp57.ID = tmp61
						}
						if v, ok := val["name"]; ok {
							var tmp62 string
							if val, ok := v.(string); ok {
								tmp62 = val
							} else {
								err = goa.InvalidAttributeTypeError(`[*].Account.Name`,  

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang goa.InvalidEnumValueError函数代码示例发布时间:2022-05-28
下一篇:
Golang parser.ValidateArguments函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap