TNG / ngqp

Declaratively synchronize form controls with the URL
https://tng.github.io/ngqp
MIT License
81 stars 8 forks source link

Restrict / Validate deserialized values #123

Closed Airblader closed 2 years ago

Airblader commented 5 years ago

What's your idea?

A common use-case is that there's only a discrete set of possible values for a parameter, but validating this is currently only possible by providing a custom deserializer which can then convert invalid values into some fallback value or similar.

We should evaluate whether a more direct approach for this could be useful, and if so, what it could look like. Some ideas:

  1. Make baking this into a deserializer easier through some factory method.
  2. Provide a restrictTo kind of option which requires & uses the already existing compareWith function
  3. Provide a separate validation function
  4. …?