本文整理匯總了Golang中github.com/go-swagger/go-swagger/errors.CompositeValidationError函數的典型用法代碼示例。如果您正苦於以下問題:Golang CompositeValidationError函數的具體用法?Golang CompositeValidationError怎麽用?Golang CompositeValidationError使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CompositeValidationError函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: BindRequest
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *UpdatePetWithFormParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
if err := r.ParseMultipartForm(32 << 20); err != nil {
return err
}
fds := httpkit.Values(r.Form)
fdName, fdhkName, _ := fds.GetOK("name")
if err := o.bindName(fdName, fdhkName, route.Formats); err != nil {
res = append(res, err)
}
rPetID, rhkPetID, _ := route.Params.GetOK("petId")
if err := o.bindPetID(rPetID, rhkPetID, route.Formats); err != nil {
res = append(res, err)
}
fdStatus, fdhkStatus, _ := fds.GetOK("status")
if err := o.bindStatus(fdStatus, fdhkStatus, route.Formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
示例2: Validate
// Validate validates this pricing component tier
func (m *PricingComponentTier) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateBillingEntity(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validateComponentID(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validateLowerThreshold(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validatePrice(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validatePricingType(formats); err != nil {
// prop
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
示例3: WriteToRequest
// WriteToRequest writes these params to a swagger request
func (o *UploadTaskFileParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {
var res []error
// form param description
frDescription := o.Description
fDescription := frDescription
if fDescription != "" {
if err := r.SetFormParam("description", fDescription); err != nil {
return err
}
}
if o.File != nil {
// form file param file
if err := r.SetFileParam("file", o.File); err != nil {
return err
}
}
// path param id
if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
示例4: WriteToRequest
// WriteToRequest writes these params to a swagger request
func (o *ManuallyStartBuildTriggerParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {
var res []error
if o.Body == nil {
o.Body = new(models.RunParameters)
}
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
// path param repository
if err := r.SetPathParam("repository", o.Repository); err != nil {
return err
}
// path param trigger_uuid
if err := r.SetPathParam("trigger_uuid", o.TriggerUUID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
示例5: WriteToRequest
// WriteToRequest writes these params to a swagger request
func (o *ChangeTokenParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {
var res []error
if o.Body == nil {
o.Body = new(models.TokenPermission)
}
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
// path param code
if err := r.SetPathParam("code", o.Code); err != nil {
return err
}
// path param repository
if err := r.SetPathParam("repository", o.Repository); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
示例6: Validate
// Validate validates this user view
func (m *UserView) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAnonymous(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validateAvatar(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validateLogins(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validateOrganizations(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validateVerified(formats); err != nil {
// prop
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
示例7: WriteToRequest
// WriteToRequest writes these params to a swagger request
func (o *FindParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {
var res []error
// header param X-Rate-Limit
if err := r.SetHeaderParam("X-Rate-Limit", swag.FormatInt32(o.XRateLimit)); err != nil {
return err
}
// form param limit
frLimit := o.Limit
fLimit := swag.FormatInt32(frLimit)
if err := r.SetFormParam("limit", fLimit); err != nil {
return err
}
var valuesTags []string
for _, v := range o.Tags {
valuesTags = append(valuesTags, swag.FormatInt32(v))
}
joinedTags := swag.JoinByFormat(valuesTags, "multi")
// form array param tags
if err := r.SetFormParam("tags", joinedTags...); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
示例8: WriteToRequest
// WriteToRequest writes these params to a swagger request
func (o *ChangeTagImageParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {
var res []error
if o.Body == nil {
o.Body = new(models.MoveTag)
}
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
// path param repository
if err := r.SetPathParam("repository", o.Repository); err != nil {
return err
}
// path param tag
if err := r.SetPathParam("tag", o.Tag); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
示例9: WriteToRequest
// WriteToRequest writes these params to a swagger request
func (o *UpdateOrganizationTeamParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {
var res []error
if o.Body == nil {
o.Body = new(models.TeamDescription)
}
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
// path param orgname
if err := r.SetPathParam("orgname", o.Orgname); err != nil {
return err
}
// path param teamname
if err := r.SetPathParam("teamname", o.Teamname); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
示例10: WriteToRequest
// WriteToRequest writes these params to a swagger request
func (o *GetPullRequestActivitiesParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {
var res []error
// query param limit
var qrLimit int64
if o.Limit != nil {
qrLimit = *o.Limit
}
qLimit := swag.FormatInt64(qrLimit)
if err := r.SetQueryParam("limit", qLimit); err != nil {
return err
}
// path param project
if err := r.SetPathParam("project", o.Project); err != nil {
return err
}
// path param pullRequestId
if err := r.SetPathParam("pullRequestId", swag.FormatInt64(o.PullRequestID)); err != nil {
return err
}
// path param repo
if err := r.SetPathParam("repo", o.Repo); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
示例11: WriteToRequest
// WriteToRequest writes these params to a swagger request
func (o *GetOrganizationTeamMembersParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {
var res []error
if o.IncludePending != nil {
// query param includePending
var qrIncludePending bool
if o.IncludePending != nil {
qrIncludePending = *o.IncludePending
}
qIncludePending := swag.FormatBool(qrIncludePending)
if qIncludePending != "" {
if err := r.SetQueryParam("includePending", qIncludePending); err != nil {
return err
}
}
}
// path param orgname
if err := r.SetPathParam("orgname", o.Orgname); err != nil {
return err
}
// path param teamname
if err := r.SetPathParam("teamname", o.Teamname); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
示例12: AgainstSchema
// AgainstSchema validates the specified data with the provided schema, when no schema
// is provided it uses the json schema as default
func AgainstSchema(schema *spec.Schema, data interface{}, formats strfmt.Registry) error {
res := validate.NewSchemaValidator(schema, nil, "", formats).Validate(data)
if res.HasErrors() {
return errors.CompositeValidationError(res.Errors...)
}
return nil
}
示例13: Spec
// Spec validates a spec document
// It validates the spec json against the json schema for swagger
// and then validates a number of extra rules that can't be expressed in json schema:
//
// - definition can't declare a property that's already defined by one of its ancestors
// - definition's ancestor can't be a descendant of the same model
// - each api path should be non-verbatim (account for path param names) unique per method
// - each security reference should contain only unique scopes
// - each security scope in a security definition should be unique
// - each path parameter should correspond to a parameter placeholder and vice versa
// - each referencable defintion must have references
// - each definition property listed in the required array must be defined in the properties of the model
// - each parameter should have a unique `name` and `type` combination
// - each operation should have only 1 parameter of type body
// - each reference must point to a valid object
// - every default value that is specified must validate against the schema for that property
// - items property is required for all schemas/definitions of type `array`
func Spec(doc *spec.Document, formats strfmt.Registry) error {
errs, _ /*warns*/ := validate.NewSpecValidator(doc.Schema(), formats).Validate(doc)
if errs.HasErrors() {
return errors.CompositeValidationError(errs.Errors...)
}
return nil
}
示例14: WriteToRequest
// WriteToRequest writes these params to a swagger request
func (o *ListRepoTagsParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {
var res []error
// query param limit
if err := r.SetQueryParam("limit", swag.FormatInt64(o.Limit)); err != nil {
return err
}
// query param page
if err := r.SetQueryParam("page", swag.FormatInt64(o.Page)); err != nil {
return err
}
// path param repository
if err := r.SetPathParam("repository", o.Repository); err != nil {
return err
}
// query param specificTag
if err := r.SetQueryParam("specificTag", o.SpecificTag); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
示例15: Validate
// Validate validates this mutable billing entity
func (m *MutableBillingEntity) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAppID(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validateAppSecret(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validateBillingEntity(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validatePlatform(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validateRefreshTokenURL(formats); err != nil {
// prop
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}