samisagit / natskell

A NATS client library written in Haskell
MIT License
5 stars 0 forks source link

Consider adding validators alongside transformers #78

Closed samisagit closed 1 year ago

samisagit commented 1 year ago

The only certainty we currently have (assuming there are no bugs in this area) is that the fields of a message sent from natskell to NATS will be of the correct 'type' for NATS to consume (type being a loose definition since they are in a string, but if something is a bool or an int for e.g we can be confident NATS will get that type. However there are cases where values of the correct type are still not valid for e.g an empty string in a mandatory string field is allowed by our client currently.

Adding a new set of functions for loosely validating the values of each field could help mitigate this. A class and class constraint could be added to ensure we're using valid types.

samisagit commented 1 year ago

It might be worth validating that the byte count sent is actually correct - which would mean storing the bytecount. Not sure now easy this is with the current record syntax used for the transformable types

samisagit commented 1 year ago

It might be worth validating that the byte count sent is actually correct - which would mean storing the bytecount. Not sure now easy this is with the current record syntax used for the transformable types

We don't need to store it, just need to expose a function that takes the given type and returns the byte count, like the other getters