func (c Validator) IsCriteriaValid(d decode.Criteria, ctx validation.Context) error { e := boom.NewError("Query error. Please fix the errors before continuing.") for _, filter := range d.Filters { switch filter.Field { case "After": if b := govalidator.IsInt(filter.Value); !b { e.AddError("After", "must be integer") } if len(d.Sorters) == 0 { e.AddError("After", "must have a sort param") } case "Before": if b := govalidator.IsInt(filter.Value); !b { e.AddError("Before", "must be integer") } if len(d.Sorters) == 0 { e.AddError("Before", "must have a sort param") } case "Latitude": values := strings.Split(filter.Value, ",") for _, value := range values { if b := govalidator.IsFloat(value); !b { e.AddError("Latitude", "must be numeric") } } case "Longitude": values := strings.Split(filter.Value, ",") for _, value := range values { if b := govalidator.IsFloat(value); !b { e.AddError("Longitude", "must be numeric") } } } } if len(e.Errors) == 0 { return nil } else { return e } }
func (i IsFloatChecker) IsFormat(data string) bool { return govalidator.IsFloat(data) }
func (s *service) IsFloat(str string) bool { return gov.IsFloat(str) }