Beispiel #1
0
func (m *TaskCard) validateTags(formats strfmt.Registry) error {

	if swag.IsZero(m.Tags) { // not required
		return nil
	}

	iTagsSize := int64(len(m.Tags))

	if err := validate.MaxItems("tags", "body", iTagsSize, 5); err != nil {
		return err
	}

	if err := validate.UniqueItems("tags", "body", m.Tags); err != nil {
		return err
	}

	for i := 0; i < len(m.Tags); i++ {

		if err := validate.RequiredString("tags"+"."+strconv.Itoa(i), "body", string(m.Tags[i])); err != nil {
			return err
		}

		if err := validate.MinLength("tags"+"."+strconv.Itoa(i), "body", string(m.Tags[i]), 3); err != nil {
			return err
		}

		if err := validate.Pattern("tags"+"."+strconv.Itoa(i), "body", string(m.Tags[i]), `\w[\w- ]+`); err != nil {
			return err
		}

	}

	return nil
}
Beispiel #2
0
func (s *stringValidator) Validate(val interface{}) *Result {
	data := val.(string)

	if s.Required && (s.Default == nil || s.Default == "") {
		if err := validate.RequiredString(s.Path, s.In, data); err != nil {
			return sErr(err)
		}
	}

	if s.MaxLength != nil {
		if err := validate.MaxLength(s.Path, s.In, data, *s.MaxLength); err != nil {
			return sErr(err)
		}
	}

	if s.MinLength != nil {
		if err := validate.MinLength(s.Path, s.In, data, *s.MinLength); err != nil {
			return sErr(err)
		}
	}

	if s.Pattern != "" {
		if err := validate.Pattern(s.Path, s.In, data, s.Pattern); err != nil {
			return sErr(err)
		}
	}
	return nil
}
func (o *DeleteOrderParams) validateOrderID(formats strfmt.Registry) error {

	if err := validate.MinLength("orderId", "path", string(o.OrderID), 1); err != nil {
		return err
	}

	return nil
}
Beispiel #4
0
func (m *Item) validateDescription(formats strfmt.Registry) error {

	if err := validate.Required("description", "body", string(m.Description)); err != nil {
		return err
	}

	if err := validate.MinLength("description", "body", string(m.Description), 1); err != nil {
		return err
	}

	return nil
}
Beispiel #5
0
func (m *Cluster) validateID(formats strfmt.Registry) error {

	if err := validate.RequiredString("id", "body", string(m.ID)); err != nil {
		return err
	}

	if err := validate.MinLength("id", "body", string(m.ID), 1); err != nil {
		return err
	}

	return nil
}
Beispiel #6
0
func (m *Component) validateName(formats strfmt.Registry) error {

	if err := validate.RequiredString("name", "body", string(m.Name)); err != nil {
		return err
	}

	if err := validate.MinLength("name", "body", string(m.Name), 1); err != nil {
		return err
	}

	return nil
}
Beispiel #7
0
func (m *Version) validateVersion(formats strfmt.Registry) error {

	if swag.IsZero(m.Version) { // not required
		return nil
	}

	if err := validate.MinLength("version", "body", string(m.Version), 1); err != nil {
		return err
	}

	return nil
}
Beispiel #8
0
func (m *TaskAttachmentsAnon) validateDescription(formats strfmt.Registry) error {

	if swag.IsZero(m.Description) { // not required
		return nil
	}

	if err := validate.MinLength("description", "body", string(m.Description), 3); err != nil {
		return err
	}

	return nil
}
Beispiel #9
0
func (m *VersionData) validateFixes(formats strfmt.Registry) error {

	if swag.IsZero(m.Fixes) { // not required
		return nil
	}

	if err := validate.MinLength("fixes", "body", string(m.Fixes), 1); err != nil {
		return err
	}

	return nil
}
Beispiel #10
0
func (m *TaskCard) validateTitle(formats strfmt.Registry) error {

	if err := validate.RequiredString("title", "body", string(m.Title)); err != nil {
		return err
	}

	if err := validate.MinLength("title", "body", string(m.Title), 5); err != nil {
		return err
	}

	if err := validate.MaxLength("title", "body", string(m.Title), 150); err != nil {
		return err
	}

	return nil
}
Beispiel #11
0
func (m *Milestone) validateName(formats strfmt.Registry) error {

	if err := validate.RequiredString("name", "body", string(m.Name)); err != nil {
		return err
	}

	if err := validate.MinLength("name", "body", string(m.Name), 3); err != nil {
		return err
	}

	if err := validate.MaxLength("name", "body", string(m.Name), 50); err != nil {
		return err
	}

	if err := validate.Pattern("name", "body", string(m.Name), `[A-Za-z][\w- ]+`); err != nil {
		return err
	}

	return nil
}
Beispiel #12
0
func (m *UserCard) validateScreenName(formats strfmt.Registry) error {

	if err := validate.RequiredString("screenName", "body", string(m.ScreenName)); err != nil {
		return err
	}

	if err := validate.MinLength("screenName", "body", string(m.ScreenName), 3); err != nil {
		return err
	}

	if err := validate.MaxLength("screenName", "body", string(m.ScreenName), 255); err != nil {
		return err
	}

	if err := validate.Pattern("screenName", "body", string(m.ScreenName), `\w[\w_-]+`); err != nil {
		return err
	}

	return nil
}