You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if math.Mod(*m.Amount, 0.01) != 0 {
return &validationError{
errType: "multipleOf",
path: []interface{}{"Amount"},
jsonPath: []interface{}{"amount"},
message: fmt.Sprintf("must be a multiple of 0.01 but was %v", *m.Amount),
}
}
So for the amount 2000, it reported the error as must be a multiple of 0.01 but was 2000
I understand the floating point characteristic makes an integer won't always return 0 when calculating math.Mod(integer, 0.01)
I have to modify it manually to correct the validation.
if math.Mod(*m.Amount*100, 1) != 0 {
return &validationError{
errType: "multipleOf",
path: []interface{}{"Amount"},
jsonPath: []interface{}{"amount"},
message: fmt.Sprintf("must be a multiple of 0.01 but was %v", *m.Amount),
}
}
The text was updated successfully, but these errors were encountered:
I have this in my schema:
The generated Validate function is
So for the amount 2000, it reported the error as
must be a multiple of 0.01 but was 2000
I understand the floating point characteristic makes an integer won't always return 0 when calculating math.Mod(integer, 0.01)
I have to modify it manually to correct the validation.
The text was updated successfully, but these errors were encountered: