这是indexloc提供的服务,不要输入任何密码
Skip to content

Fix validator messages - they are mostly off by one #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions vercel/validator_float64_greater_than.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ type validatorFloat64GreaterThan struct {
}

func (v validatorFloat64GreaterThan) Description(ctx context.Context) string {
return fmt.Sprintf("Value must be greater than %.2f", v.Min)
return fmt.Sprintf("Value must be equal to or greater than %.2f", v.Min)
}
func (v validatorFloat64GreaterThan) MarkdownDescription(ctx context.Context) string {
return fmt.Sprintf("Value must be greater than `%.2f`", v.Min)
return fmt.Sprintf("Value must be equal to or greater than `%.2f`", v.Min)
}

func (v validatorFloat64GreaterThan) ValidateFloat64(ctx context.Context, req validator.Float64Request, resp *validator.Float64Response) {
Expand Down
4 changes: 2 additions & 2 deletions vercel/validator_float64_less_than.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ type validatorFloat64LessThan struct {
}

func (v validatorFloat64LessThan) Description(ctx context.Context) string {
return fmt.Sprintf("Value must be less than %.2f", v.Max)
return fmt.Sprintf("Value must be equal to or less than %.2f", v.Max)
}
func (v validatorFloat64LessThan) MarkdownDescription(ctx context.Context) string {
return fmt.Sprintf("Value must be less than `%.2f`", v.Max)
return fmt.Sprintf("Value must be equal to or less than `%.2f`", v.Max)
}

func (v validatorFloat64LessThan) ValidateFloat64(ctx context.Context, req validator.Float64Request, resp *validator.Float64Response) {
Expand Down
4 changes: 2 additions & 2 deletions vercel/validator_int64_greater_than.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ type validatorInt64GreaterThan struct {
}

func (v validatorInt64GreaterThan) Description(ctx context.Context) string {
return fmt.Sprintf("Value must be greater than %d", v.Min)
return fmt.Sprintf("Value must be equal to or greater than %d", v.Min)
}
func (v validatorInt64GreaterThan) MarkdownDescription(ctx context.Context) string {
return fmt.Sprintf("Value must be greater than `%d`", v.Min)
return fmt.Sprintf("Value must be equal to or greater than `%d`", v.Min)
}

func (v validatorInt64GreaterThan) ValidateInt64(ctx context.Context, req validator.Int64Request, resp *validator.Int64Response) {
Expand Down
4 changes: 2 additions & 2 deletions vercel/validator_int64_less_than.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ type validatorInt64LessThan struct {
}

func (v validatorInt64LessThan) Description(ctx context.Context) string {
return fmt.Sprintf("Value must be less than %d", v.Max)
return fmt.Sprintf("Value must be equal to or less than %d", v.Max)
}
func (v validatorInt64LessThan) MarkdownDescription(ctx context.Context) string {
return fmt.Sprintf("Value must be less than `%d`", v.Max)
return fmt.Sprintf("Value must be equal to or less than `%d`", v.Max)
}

func (v validatorInt64LessThan) ValidateInt64(ctx context.Context, req validator.Int64Request, resp *validator.Int64Response) {
Expand Down
4 changes: 2 additions & 2 deletions vercel/validator_map_items_min_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ type validatorMapItemsMinCount struct {
}

func (v validatorMapItemsMinCount) Description(ctx context.Context) string {
return fmt.Sprintf("Map must contain at least %d item(s)", v.Min)
return fmt.Sprintf("Map must contain %d or more item(s)", v.Min)
}
func (v validatorMapItemsMinCount) MarkdownDescription(ctx context.Context) string {
return fmt.Sprintf("Map must contain at least `%d` item(s)", v.Min)
return fmt.Sprintf("Map must contain %d or more item(s)", v.Min)
}

func (v validatorMapItemsMinCount) ValidateMap(ctx context.Context, req validator.MapRequest, resp *validator.MapResponse) {
Expand Down
4 changes: 2 additions & 2 deletions vercel/validator_map_max_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ type validatorMapMaxCount struct {
}

func (v validatorMapMaxCount) Description(ctx context.Context) string {
return fmt.Sprintf("Map must contain fewer than %d items", v.Max)
return fmt.Sprintf("Map must contain %d or fewer items", v.Max)
}
func (v validatorMapMaxCount) MarkdownDescription(ctx context.Context) string {
return fmt.Sprintf("Map must contain fewer than %d items", v.Max)
return fmt.Sprintf("Map must contain %d or fewer items", v.Max)
}

func (v validatorMapMaxCount) ValidateMap(ctx context.Context, req validator.MapRequest, resp *validator.MapResponse) {
Expand Down
4 changes: 2 additions & 2 deletions vercel/validator_string_length_greater_than.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ type validatorStringLengthGreaterThan struct {
}

func (v validatorStringLengthGreaterThan) Description(ctx context.Context) string {
return fmt.Sprintf("String length must be greater than %d", v.Min)
return fmt.Sprintf("String length must be equal to or greater than %d", v.Min)
}

func (v validatorStringLengthGreaterThan) MarkdownDescription(ctx context.Context) string {
return fmt.Sprintf("String length must be greater than %d", v.Min)
return fmt.Sprintf("String length must be equal to or greater than %d", v.Min)
}

func (v validatorStringLengthGreaterThan) ValidateString(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) {
Expand Down
4 changes: 2 additions & 2 deletions vercel/validator_string_set_min_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ type validatorStringSetMinCount struct {
}

func (v validatorStringSetMinCount) Description(ctx context.Context) string {
return fmt.Sprintf("Set must contain at least %d items", v.Min)
return fmt.Sprintf("Set must contain %d or more items", v.Min)
}
func (v validatorStringSetMinCount) MarkdownDescription(ctx context.Context) string {
return fmt.Sprintf("Set must contain at least %d items", v.Min)
return fmt.Sprintf("Set must contain %d or more items", v.Min)
}

func (v validatorStringSetMinCount) ValidateSet(ctx context.Context, req validator.SetRequest, resp *validator.SetResponse) {
Expand Down