[racket] formlets and validation

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Wed Mar 30 11:08:26 EDT 2011

2011/3/29 Eric Tanter <etanter at dcc.uchile.cl>:
> Hi,
> I'm exploring formlets (enjoying them for the most part!), and I'm wondering what is the best way to handle input validation. Following the tutorial/guide on formlets results in the web app throwing exceptions whenever formlet-process encounters improper bindings.
> (eg. self-contract violation: expected <integer?>, given: #f
>  contract on input-int from ...)
> However, those are not really helpful for the user.
> I'm wondering:
> a- is there a way to specify some validation to be done on the client side?

No. I think it would be nice to do a little DSL that does that, but I have not.

> if not:
> b- is there a best practice to expose users to their malformed input in a precise manner? (ie. which input field was incorrectly filled)

I've played with a maybe-formlet that catches exceptions in the
processing step of its argument and then coded in the behavior of the
result page to show the problems. I haven't found an API that I really

This would be a good place to improve in the Web Server. I plan on
doing it as I need to in my apps, but I'd love to see what ideas, etc
others have. I'm happy too to take something useful that others make
and improve and support it.


> Thanks!
> -- Éric
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users

Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University

"The glory of God is Intelligence" - D&C 93

Posted on the users mailing list.