Formify Docs

Numeric

Validate that a value is a number, including decimals and negative values.

Numeric

Validates that a value is a number. Accepts integers, decimals, negative values, and zero. Does not accept whitespace or non-numeric characters.

Configuration

Config flagTypeDescription
numericbooleanWhen true, requires the value to be numeric.

With useForm

const form = useForm({
  initialValues: { price: '' },
  validationSchema: {
    price: { numeric: true },
  },
});

With the V builder

import { V } from 'formify-js';

V.numeric();

Default message

ScenarioMessage
Value is not a numberMust be a number

Examples

ValueResult
'123'✅ Valid
'12.5'✅ Valid
'-7'✅ Valid
'0'✅ Valid
'12,5'❌ Invalid (comma decimal separator not accepted)
' 123 '❌ Invalid (whitespace)

Notes

  • Use integer when decimals should be rejected.
  • Use decimal when a decimal point is required.

On this page