JamesLMilner / terra-draw

A library for drawing on maps that supports Mapbox, MapLibre, Google Maps, OpenLayers and Leaflet out the box
https://terradraw.io
MIT License
447 stars 50 forks source link

feat: add validate to all built in modes #257

Closed JamesLMilner closed 3 months ago

JamesLMilner commented 3 months ago

Description of Changes

The main premise here is to provide a more generalised way to validate drawn features. This allows developers using Terra Draw to define their own custom logic for validating drawn features.

It also aligns the validateFeature function with this new validate option for all built in modes. We centralise around the idea of Validations which are essentially predicate functions. validateFeature will now also run the validate function passed as part of any call to it (i.e. via addFeatures).

It attempts to add comprehensive tests and docs to accommodate for the changes.

Link to Issue

256

PR Checklist