number
Accepts finite numbers (can be integer or float values). ValuesNaN, or positive and negative Infinity will get rejected.
Validation Rules
- Must be a JavaScript number type
- Must be finite (rejects
NaN,Infinity, and-Infinity) - Accepts both integers and floats
- Accepts negative and positive numbers
Examples
Use Cases
- General numeric values
- Calculations and measurements
- Coordinates and positions
- Default choice for most number validations
anyNumber
Accepts any validnumber value.
This also accepts special values like NaN and Infinity. Unless you want to deliberately accept those, you’ll likely want to use the number decoder instead.
Validation Rules
- Must be a JavaScript number type
- Accepts
NaN,Infinity, and-Infinity - Accepts all finite numbers
Examples
Use Cases
- Mathematical operations that may produce
NaNorInfinity - Serialization/deserialization where special values are valid
- Low-level number processing
numeric
Accepts valid numerical strings (in base-10) and returns them as a number. To only accept numerical strings and keep them as string values, use thedecimal decoder.
Validation Rules
- Must be a string type
- Must contain only decimal digits (0-9)
- Returns the parsed number value
- Uses base-10 conversion
Examples
Use Cases
- Parsing numeric strings from forms
- URL parameters that should be numbers
- String-based API responses with numeric values
- CSV or text file parsing
Related
decimal- Accepts numeric strings but keeps them as stringsnumber- For direct number values (not strings)
