Fork me on GitHub
#malli
<
2023-05-04
>
Sam14:05:20

Repost from #beginners!

Ben Sless15:05:05

My best advice is avoid fn schema at all cost. There's always a better way to write your schema. If it's very special, write a custom schema You can also use transformers to massage your data into a form which makes it easy to validate without a fn schema Write a property based test that makes sure all schemas you generate are valid Decoders and encoders are your friends, schemas represent ought, not is, let decoders do the heavy lifting for you. String schemas are suspect

3
Sam19:05:04

Thank you!

Sam06:05:22

And to clarify, what I've been doing, verifying the schema at the start of the function, is reasonable? Is that how people do it?

Ben Sless07:05:30

Depends on your use case, but my suggestion is validate it when data comes in from the outside world into your process, and when it goes out of process (e.g. side effects) You might want to check it in key interface points inside your program if it's large But schemas aren't meant to validate all your functions' inputs at runtime

❤️ 2
Sam07:05:57

Sounds good, thanks!