我正在使用JSON Schema驗證服務器請求,並且我有一些值希望驗證爲2DP。我用下面的架構來驗證這些字段:JSON Schema給我multipleOf 0.01的驗證錯誤以.49或.99結尾的任何數字
'properties': {
'amount': {'type': ['number', 'null'], 'multipleOf': 0.01}
}
這工作正常比.49或.99,在那裏我得到的錯誤amount is not a multiple of (divisible by) 0.01
結尾號碼之外的所有情況。
這可能是某種浮點錯誤。如果這是不正確的,我應該如何驗證數字到一定的精度?
我不得不定義選項multipleOfPrecision在ajv https://github.com/epoberezkin/ajv – esp