terra-draw
terra-draw copied to clipboard
[Feature Request] Bring validation functionality from select mode to all drawing modes
Is your feature request related to a problem? Please describe.
We added the validation option to TerraDrawSelectMode, which allows users to validate a geometry before a edit is committed. I've realised this is a good model to use for the actual validation of creation of geometries whilst drawing in other modes too. Instead of using allowSelfIntersections we should expose a Validation called ValidateNonSelfIntersecting which can be used in the validation function. This makes the ability for adding drawing rules very broad and powerful, and they can be applied uniformly across drawing and selecting.
Describe your proposed idea for the solution to this problem
We will have a validation property for all built in drawing modes to ensure that users can pass their own validation rules before the feature is committed.
Describe alternatives you've considered We have been using individual properties like 'allowSelfIntersections' to try and provide restrictions to drawing certain shapes. This is a good start, but actually quite restrictive. For example, if I want to have a minimum and maximum polygon size, and I also want it to have no self intersections, that is currently not possible.
Additional context No other context to add