コード例 #1
0
// 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
}
コード例 #2
0
// 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
}
コード例 #3
0
// 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
0
// 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
0
// 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
0
ファイル: user_view.go プロジェクト: carriercomm/go-quay
// 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
0
// 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
0
// 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
0
// 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
}
// 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
0
// 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
0
ファイル: spec.go プロジェクト: MStoykov/go-swagger
// 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
0
ファイル: spec.go プロジェクト: MStoykov/go-swagger
// 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
0
// 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
0
// 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
}
コード例 #16
0
// Validate validates this pricing component value
func (m *PricingComponentValue) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateBillingEntity(formats); err != nil {
		// prop
		res = append(res, err)
	}

	if err := m.validateID(formats); err != nil {
		// prop
		res = append(res, err)
	}

	if err := m.validatePricingComponentID(formats); err != nil {
		// prop
		res = append(res, err)
	}

	if err := m.validateSubscriptionID(formats); err != nil {
		// prop
		res = append(res, err)
	}

	if err := m.validateValue(formats); err != nil {
		// prop
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
コード例 #17
0
// WriteToRequest writes these params to a swagger request
func (o *ConductSearchParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {

	var res []error

	if o.Query != nil {

		// query param query
		var qrQuery string
		if o.Query != nil {
			qrQuery = *o.Query
		}
		qQuery := qrQuery
		if qQuery != "" {
			if err := r.SetQueryParam("query", qQuery); err != nil {
				return err
			}
		}

	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
コード例 #18
0
// Validate validates this payment method subscription link
func (m *PaymentMethodSubscriptionLink) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateBillingEntity(formats); err != nil {
		// prop
		res = append(res, err)
	}

	if err := m.validatePaymentMethodID(formats); err != nil {
		// prop
		res = append(res, err)
	}

	if err := m.validateSubscription(formats); err != nil {
		// prop
		res = append(res, err)
	}

	if err := m.validateSubscriptionID(formats); err != nil {
		// prop
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
コード例 #19
0
// WriteToRequest writes these params to a swagger request
func (o *GetRepoTagVulnerabilitiesParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {

	var res []error

	if o.MinimumPriority != nil {

		// query param minimumPriority
		var qrMinimumPriority string
		if o.MinimumPriority != nil {
			qrMinimumPriority = *o.MinimumPriority
		}
		qMinimumPriority := qrMinimumPriority
		if qMinimumPriority != "" {
			if err := r.SetQueryParam("minimumPriority", qMinimumPriority); 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
}
コード例 #20
0
ファイル: find_parameters.go プロジェクト: jak-atx/vic
// 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 *FindParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
	var res []error
	if err := r.ParseMultipartForm(32 << 20); err != nil {
		if err != http.ErrNotMultipart {
			return err
		} else if err := r.ParseForm(); err != nil {
			return err
		}
	}
	fds := httpkit.Values(r.Form)

	if err := o.bindXRateLimit(r.Header["X-Rate-Limit"], true, route.Formats); err != nil {
		res = append(res, err)
	}

	fdLimit, fdhkLimit, _ := fds.GetOK("limit")
	if err := o.bindLimit(fdLimit, fdhkLimit, route.Formats); err != nil {
		res = append(res, err)
	}

	fdTags, fdhkTags, _ := fds.GetOK("tags")
	if err := o.bindTags(fdTags, fdhkTags, route.Formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
コード例 #21
0
// WriteToRequest writes these params to a swagger request
func (o *ListOrgLogsParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {

	var res []error

	// query param endtime
	if err := r.SetQueryParam("endtime", o.Endtime); err != nil {
		return err
	}

	// path param orgname
	if err := r.SetPathParam("orgname", o.Orgname); err != nil {
		return err
	}

	// query param page
	if err := r.SetQueryParam("page", swag.FormatInt64(o.Page)); err != nil {
		return err
	}

	// query param performer
	if err := r.SetQueryParam("performer", o.Performer); err != nil {
		return err
	}

	// query param starttime
	if err := r.SetQueryParam("starttime", o.Starttime); err != nil {
		return err
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
コード例 #22
0
// WriteToRequest writes these params to a swagger request
func (o *GetOrgRobotsParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {

	var res []error

	// path param orgname
	if err := r.SetPathParam("orgname", o.Orgname); err != nil {
		return err
	}

	if o.Permissions != nil {

		// query param permissions
		var qrPermissions bool
		if o.Permissions != nil {
			qrPermissions = *o.Permissions
		}
		qPermissions := swag.FormatBool(qrPermissions)
		if qPermissions != "" {
			if err := r.SetQueryParam("permissions", qPermissions); err != nil {
				return err
			}
		}

	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
// WriteToRequest writes these params to a swagger request
func (o *UpdateOrganizationPrototypePermissionParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {

	var res []error

	if o.Body == nil {
		o.Body = new(models.PrototypeUpdate)
	}

	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 prototypeid
	if err := r.SetPathParam("prototypeid", o.Prototypeid); err != nil {
		return err
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
コード例 #24
0
// Validate validates this insertable billing entity
func (m *InsertableBillingEntity) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateAccount(formats); err != nil {
		// prop
		res = append(res, err)
	}

	if err := m.validateAccountID(formats); err != nil {
		// prop
		res = append(res, err)
	}

	if err := m.validateBillingEntity(formats); err != nil {
		// prop
		res = append(res, err)
	}

	if err := m.validateOrganizationID(formats); err != nil {
		// prop
		res = append(res, err)
	}

	if err := m.validateRole(formats); err != nil {
		// prop
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
コード例 #25
0
// 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 *UploadFileParams) 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)

	fdAdditionalMetadata, fdhkAdditionalMetadata, _ := fds.GetOK("additionalMetadata")
	if err := o.bindAdditionalMetadata(fdAdditionalMetadata, fdhkAdditionalMetadata, route.Formats); err != nil {
		res = append(res, err)
	}

	file, fileHeader, err := r.FormFile("file")
	if err != nil {
		res = append(res, errors.New(400, "reading file %q failed: %v", "file", err))
	} else {
		o.File = httpkit.File{Data: file, Header: fileHeader}
	}

	rPetID, rhkPetID, _ := route.Params.GetOK("petId")
	if err := o.bindPetID(rPetID, rhkPetID, route.Formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
コード例 #26
0
// WriteToRequest writes these params to a swagger request
func (o *ListTriggerRecentBuildsParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {

	var res []error

	if o.Limit != nil {

		// query param limit
		var qrLimit int64
		if o.Limit != nil {
			qrLimit = *o.Limit
		}
		qLimit := swag.FormatInt64(qrLimit)
		if qLimit != "" {
			if err := r.SetQueryParam("limit", qLimit); 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
}
コード例 #27
0
// 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 *ListTasksParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
	var res []error
	qs := httpkit.Values(r.URL.Query())

	qPageSize, qhkPageSize, _ := qs.GetOK("pageSize")
	if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil {
		res = append(res, err)
	}

	qSinceID, qhkSinceID, _ := qs.GetOK("sinceId")
	if err := o.bindSinceID(qSinceID, qhkSinceID, route.Formats); err != nil {
		res = append(res, err)
	}

	qStatus, qhkStatus, _ := qs.GetOK("status")
	if err := o.bindStatus(qStatus, qhkStatus, route.Formats); err != nil {
		res = append(res, err)
	}

	qTags, qhkTags, _ := qs.GetOK("tags")
	if err := o.bindTags(qTags, qhkTags, route.Formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
コード例 #28
0
// WriteToRequest writes these params to a swagger request
func (o *DiscoveryParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {

	var res []error

	if o.Internal != nil {

		// query param internal
		var qrInternal bool
		if o.Internal != nil {
			qrInternal = *o.Internal
		}
		qInternal := swag.FormatBool(qrInternal)
		if qInternal != "" {
			if err := r.SetQueryParam("internal", qInternal); err != nil {
				return err
			}
		}

	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
コード例 #29
0
// 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 *UpdateOneParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
	var res []error

	var body models.Item
	if err := route.Consumer.Consume(r.Body, &body); err != nil {
		res = append(res, errors.NewParseError("body", "body", "", err))
	} else {
		if err := body.Validate(route.Formats); err != nil {
			res = append(res, err)
		}

		if len(res) == 0 {
			o.Body = &body
		}
	}

	rID, rhkID, _ := route.Params.GetOK("id")
	if err := o.bindID(rID, rhkID, route.Formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
コード例 #30
0
// WriteToRequest writes these params to a swagger request
func (o *UpdateOrganizationApplicationParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {

	var res []error

	if o.Body == nil {
		o.Body = new(models.UpdateApp)
	}

	if err := r.SetBodyParam(o.Body); err != nil {
		return err
	}

	// path param client_id
	if err := r.SetPathParam("client_id", o.ClientID); err != nil {
		return err
	}

	// path param orgname
	if err := r.SetPathParam("orgname", o.Orgname); err != nil {
		return err
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}