-1

In my Sanity.io project I have a schema with input field with type number. I am trying to use it to represent currency or money. The issue is that when I publish value that has number ending with 0, the zero gets removed

Example: 3.00 is stored as 3 or 3.50 is stored as 3.5

This cases an issue because when it display on my front end I am expecting it to show as it was original type in the studio

defineField({
      name: "price",
      title: "Price",
      description: "Example: 2.99 (Do not $)",
      type: "number",
      validation: (Rule) => Rule.required().positive().precision(2),
    }),
user207421
  • 305,947
  • 44
  • 307
  • 483
  • 1
    After the decimal *point.* Decimal is a radix, not a position. The behaviour you describe is correct. This is a formatting issue, not a storage issue. – user207421 Aug 18 '23 at 00:25

0 Answers0