4 <STRONG>form_field_validation</STRONG> - data type validation for fields
9 <STRONG>#include</STRONG> <STRONG><form.h></STRONG>
10 int set_field_type(FIELD *field, FIELDTYPE *type, ...);
11 FIELDTYPE *field_type(const FIELD *field);
12 void *field_arg(const FIELD *field);
16 <H2>DESCRIPTION</H2><PRE>
17 The function <STRONG>set_field_type</STRONG> declares a data type for a
18 given form field. This is the type checked by validation
19 functions. The types are as follows:
22 Alphanumeric data. Requires a third <STRONG>int</STRONG> argument, a
26 Character data. Requires a third <STRONG>int</STRONG> argument, a
30 Accept one of a specified set of strings. Requires a
31 third <STRONG>(char</STRONG> <STRONG>**)</STRONG> argument pointing to a string list; a
32 fourth <STRONG>int</STRONG> flag argument to enable case-sensitivity;
33 and a fifth <STRONG>int</STRONG> flag argument specifying whether a
34 partial match must be a unique one (if this flag is
35 off, a prefix matches the first of any set of more
36 than one list elements with that prefix). Please
37 notice that the string list is not copied, only a
38 reference to it is stored in the field. So you should
39 avoid to use a list that lives in automatic variables
43 Integer data, parsable to an integer by <STRONG>atoi(3)</STRONG>.
44 Requires a third <STRONG>int</STRONG> argument controlling the preci-
45 sion, a fourth <STRONG>long</STRONG> argument constraining minimum
46 value, and a fifth <STRONG>long</STRONG> constraining maximum value.
47 If the maximum value is less or equal the minimum
48 value, the range is simply ignored. On return the
49 field buffer is formatted according to the <STRONG>printf</STRONG>
50 format specification ".*ld", where the '*' is
51 replaced by the precision argument. For details of
52 the precision handling see <STRONG>printf's</STRONG> man-page.
55 Numeric data (may have a decimal-point part).
56 Requires a third <STRONG>int</STRONG> argument controlling the preci-
57 sion, a fourth <STRONG>double</STRONG> argument constraining minimum
58 value, and a fifth <STRONG>double</STRONG> constraining maximum value.
59 If your system supports locale's, the decimal point
60 the minimum value, the range is simply ignored. On
61 return the field buffer is formatted according to the
62 <STRONG>printf</STRONG> format specification ".*f", where the '*' is
63 replaced by the precision argument. For details of
64 the precision handling see <STRONG>printf's</STRONG> man-page.
67 Regular expression data. Requires a regular expres-
68 sion <STRONG>(char</STRONG> <STRONG>*)</STRONG> third argument; the data is valid if
69 the regular expression matches it. Regular expres-
70 sions are in the format of <STRONG><A HREF="regcomp.3x.html">regcomp(3X)</A></STRONG> and
71 <STRONG><A HREF="regexec.3x.html">regexec(3X)</A></STRONG>. Please notice that the regular expres-
72 sion must match the whole field. If you have for
73 example an eight character wide field, a regular
74 expression "^[0-9]*$" always means that you have to
75 fill all eight positions with digits. If you want to
76 allow fewer digits, you may use for example "^[0-9]*
77 *$" which is good for trailing spaces (up to an empty
78 field), or "^ *[0-9]* *$" which is good for leading
79 and trailing spaces around the digits.
82 An Internet Protocol Version 4 address. This requires
83 no additional argument. It is checked whether or not
84 the buffer has the form a.b.c.d, where a,b,c and d
85 are numbers between 0 and 255. Trailing blanks in the
86 buffer are ignored. The address itself is not vali-
87 dated. Please note that this is an ncurses extension.
88 This field type may not be available in other curses
91 It is possible to set up new programmer-defined field
92 types. See the <STRONG><A HREF="form_fieldtype.3x.html">form_fieldtype(3X)</A></STRONG> manual page.
96 <H2>RETURN VALUE</H2><PRE>
97 The functions <STRONG>field_type</STRONG> and <STRONG>field_arg</STRONG> return <STRONG>NULL</STRONG> on
98 error. The function <STRONG>set_field_type</STRONG> returns one of the fol-
101 <STRONG>E_OK</STRONG> The routine succeeded.
103 <STRONG>E_SYSTEM_ERROR</STRONG>
104 System error occurred (see <STRONG>errno</STRONG>).
108 <H2>SEE ALSO</H2><PRE>
109 <STRONG><A HREF="ncurses.3x.html">curses(3X)</A></STRONG>, <STRONG><A HREF="form.3x.html">form(3X)</A></STRONG>.
114 The header file <STRONG><form.h></STRONG> automatically includes the header
115 file <STRONG><curses.h></STRONG>.
119 <H2>PORTABILITY</H2><PRE>
123 <H2>AUTHORS</H2><PRE>
124 Juergen Pfeifer. Manual pages and adaptation for new
125 curses by Eric S. Raymond.