Example #1
0
func (m *TaskCard) validateKarma(formats strfmt.Registry) error {

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

	if err := validate.Minimum("karma", "body", float64(*m.Karma), 0, true); err != nil {
		return err
	}

	if err := validate.MultipleOf("karma", "body", float64(*m.Karma), 0.5); err != nil {
		return err
	}

	return nil
}
Example #2
0
func (m *TaskCard) validateEffort(formats strfmt.Registry) error {

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

	if err := validate.Maximum("effort", "body", float64(*m.Effort), 27, false); err != nil {
		return err
	}

	if err := validate.MultipleOf("effort", "body", float64(*m.Effort), 3); err != nil {
		return err
	}

	return nil
}
Example #3
0
func (n *numberValidator) Validate(val interface{}) *Result {
	data := n.convertToFloat(val)

	if n.MultipleOf != nil {
		if err := validate.MultipleOf(n.Path, n.In, data, *n.MultipleOf); err != nil {
			return sErr(err)
		}
	}
	if n.Maximum != nil {
		if err := validate.Maximum(n.Path, n.In, data, *n.Maximum, n.ExclusiveMaximum); err != nil {
			return sErr(err)
		}
	}
	if n.Minimum != nil {
		if err := validate.Minimum(n.Path, n.In, data, *n.Minimum, n.ExclusiveMinimum); err != nil {
			return sErr(err)
		}
	}
	result := new(Result)
	result.Inc()
	return result
}