3 ms·
Hi, you can see a smaller example on ryelang.org front page if you ctrl+f "validation". Here are unit tests / reference for the validation dialect, but they ar
by middayc 3y ago
Hi, you can see a smaller example on ryelang.org front page if you ctrl+f "validation".
Here are unit tests / reference for the validation dialect, but they aren't the best source of information: https://ryelang.org/validation.html https://ryelang.org/validation.html
Here is an old blogpost with another example: https://ryelang.blogspot.com/2021/01/added-intro-pages-for-hof-s-validation.html https://ryelang.blogspot.com/2021/01/added-intro-pages-for-h...
It's a dialect with static/builtin rules that can be combined and two rules that accpet blocks of Rye code so they can do anything (check and calc, first checks value for certain condition, second changes / calculates new value from the old)
I've written about validation dialect in previous attempts, but current one "Meet Rye" is still in the process of being written and I will get to this.
- carterschonwald 3y agoIt’s definitely an idea which I’ve seen people wish Haskell had. But requires some machinery that’s not quite in that language. I guess it’s easy to express in a dependently typed language to an extent.
- middayc 3y agoThis validation dialect (and SQL dialect are main things) I used in all my web development for years using Rebol. So in Rye I made it part of the base builtins. It's nothing particularly special or complicated and could be improved to cover more cases. I then had custom functions in Rebol that instead of argument list accepted this validation block and what it returned gor serialized into JSON and returned from the webserver. In case of valiadation error it also got automatically returned and sent back. So you defined such fucntions in a context and got an web accesible API and also you could call them on serverside to render something there (or fill in JSON directly into page that is served). Function in Rebol (and Rye) also have a docstring and it's accesible within the language so these functions could also self-document. Show their description and validation rules if you called them with &_x=1 (as in explore mode). Of course I tried to redo all this in Rye and make it even better for this. Ok ... I got a little carried away ... :)