Ejemplo n.º 1
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 *UpdatePetWithFormParams) bindStatus(raw string, formats strfmt.Registry) error {
	if err := validate.RequiredString("status", "formData", raw); err != nil {
		return err
	}

	o.Status = raw

	if err := o.validateStatus(formats); err != nil {
		return err
	}

	return nil
}
func (o *UpdatePetWithFormParams) bindName(raw string, formats strfmt.Registry) error {
	if err := validate.RequiredString("name", "formData", raw); err != nil {
		return err
	}

	o.Name = raw

	if err := o.validateName(formats); err != nil {
		return err
	}

	return nil
}
func (o *DeletePetParams) bindAPIKey(raw string, formats strfmt.Registry) error {
	if err := validate.RequiredString("apiKey", "header", raw); err != nil {
		return err
	}

	o.APIKey = raw

	if err := o.validateAPIKey(formats); err != nil {
		return err
	}

	return nil
}