Can't enter 0 in Sanity number field despite min(0) rule

4 replies
Last updated: Dec 1, 2025
Hello, for some reason we can't enter 0 into the number field. I've tried setting custom Rules for positive() and min(0) to no avail.
Am I missing anything.
AI Update

This is a puzzling issue! According to Sanity's official documentation, the positive() validation rule should actually allow zero - it's defined as requiring "the number to be positive (>= 0)", which includes zero. So theoretically, using either positive() or min(0) should let you enter 0.

Since the expected behavior isn't working, here are some troubleshooting steps:

1. Remove positive() and use only min(0)

Even though positive() should work, try simplifying to just:

defineField({
  name: 'yourNumberField',
  type: 'number',
  validation: (Rule) => Rule.min(0)
})

2. Check for validation rule conflicts

If you're chaining multiple validation rules, make sure they're not conflicting. The validation documentation mentions that validation cascades - if you're referencing this field type from another schema, higher-level rules might be overriding your field-level validation.

3. Try setting an explicit initial value

Sometimes number fields can behave oddly with falsy values:

defineField({
  name: 'yourNumberField',
  type: 'number',
  initialValue: 0,
  validation: (Rule) => Rule.min(0)
})

4. Temporarily remove ALL validation

This will help isolate whether it's actually a validation issue:

defineField({
  name: 'yourNumberField',
  type: 'number'
  // No validation at all
})

If you can enter 0 without validation, then there's something specific about your validation setup causing the issue.

5. Check for custom input components

If you have any custom components: { input: ... } defined on this field, they might be interfering with how zero values are handled.

If none of these work, could you share your complete field definition? There might be something else in your schema configuration that's blocking zero values. This behavior definitely doesn't match what the documentation says should happen!

Show original thread
4 replies

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?