0

how to Allow leading zero's, I am getting the below exception,

Caused by: org.springframework.core.codec.DecodingException: JSON decoding error: Invalid numeric value: Leading zeroes not allowed; nested exception is com.fasterxml.jackson.core.JsonParseException: Invalid numeric value: Leading zeroes not allowed
 at [Source: (org.springframework.core.io.buffer.DefaultDataBuffer$DefaultDataBufferInputStream); line: 4, column: 21]

the swagger definition for the amount with Regex,

 "amount": {
      "type": "number",
      "description": "The amount of tnx",
      "pattern" : "^-?[0-9]*(\\.([0-9]{1,2}))?$",
      "example" : "9999.99"
    }, 

Working test: "amount": 6.81

not Working test with exception: "amount": 06.81

jcrshankar
  • 1,165
  • 8
  • 25
  • 45
  • Does these links answer your question? -- [Why is JSON invalid if an integer begins with a leading zero?](https://stackoverflow.com/q/27361565/113116), [Numbers cannot begin with a zero in JSON?](https://stackoverflow.com/q/46345894/113116) – Helen Dec 12 '22 at 18:45

0 Answers0