[REBOL] Re: Input validation routines
From: didier:cadieu:freesbee at: 27-Aug-2003 23:01
Re: Input validation routines
> Hi, has someone written a set of input validation routines/dialect,
> where I can check data against some format specification? Those things
> one knows from Excel, databases etc. for dates, number, strings, length
> of input and so on. Thanks. Robert
I have made a custom field style to convert on the fly user input to another datatype.
This face also filter the key allowed to be entered in the field. So the user can't input
any forbidden char.
For exemple, to input an integer value by allowing only digit and minus, the layout spec
will be :
view layout [
filter-field convert-to integer! filter "-0123456789"
'convert-to and 'filter are specifics to this style and optional of course.
'convert-to can be follow by the desire datatype or by a function that take the face
for parameters and must return the result of the conversion. the result is stored in
the property "value" of the object and is set to none! if the conversion failed. By default,
"value" is a copy of "text"
'filter can be follow by a string!, a block of char/string (like 'charset function one)
or a bitset!. In all case this value represent the char that can be typed by the user.
If the key pressed is not in this spec, the input value is discard and doesn't appear
in the field.
You can find this style and a test script here :
or on my rebsite :
(REM: click "filter-field-style" to put it in the cache before trying the demo)
Doc and more examples are in the header of filter-field-style.r
Hope it can help you