Validates a zoom level against a range.
Defaults to [0, 20], both inclusive. NaN and the infinities are rejected explicitly, so a value that arithmetic produced rather than a user is caught here rather than downstream.
[0, 20]
NaN
The zoom level.
Range plus ValidatorOptions; min defaults to 0, max to 20.
min
0
max
20
{ valid, error }; error is null when valid.
{ valid, error }
error
null
GeoLeafError A ValidationError when out of range and throwOnError is set.
ValidationError
throwOnError
GeoLeaf.Validators.validateZoom(12);// Returns: { valid: true, error: null }GeoLeaf.Validators.validateZoom(25);// Returns: { valid: false, error: 'Zoom must be between 0 and 20' }// Custom rangeGeoLeaf.Validators.validateZoom(15, { min: 5, max: 18 });// Returns: { valid: true, error: null } Copy
GeoLeaf.Validators.validateZoom(12);// Returns: { valid: true, error: null }GeoLeaf.Validators.validateZoom(25);// Returns: { valid: false, error: 'Zoom must be between 0 and 20' }// Custom rangeGeoLeaf.Validators.validateZoom(15, { min: 5, max: 18 });// Returns: { valid: true, error: null }
Validates a zoom level against a range.
Defaults to
[0, 20], both inclusive.NaNand the infinities are rejected explicitly, so a value that arithmetic produced rather than a user is caught here rather than downstream.