Longitude
Validate longitude coordinates in decimal degrees.
Validates that a value is a longitude coordinate in decimal degrees, in the range -180 to 180.
| Config flag | Type | Description |
|---|
longitude | boolean | When true, requires the value to be a valid longitude. |
const form = useForm({
initialValues: { lng: '' },
validationSchema: {
lng: { longitude: true },
},
});
import { V } from 'formify-js';
V.longitude();
| Scenario | Message |
|---|
| Value is not a valid longitude | Must be a valid longitude |
| Value | Result |
|---|
'-0.1278' | ✅ Valid |
'139.6917' | ✅ Valid |
'180' | ✅ Valid (antimeridian) |
'-181' | ❌ Invalid (out of range) |
'12.3E' | ❌ Invalid (direction suffix not accepted) |
- Values outside
-180 … 180 fail.
- Direction suffixes (
E/W) and degree symbols are not accepted — use plain decimal degrees.
- Combine with
latitude to validate coordinate pairs on separate fields.