2 .TH form_field_validation 3X ""
4 \fBform_field_validation\fR - data type validation for fields
6 \fB#include <form.h>\fR
8 int set_field_type(FIELD *field, FIELDTYPE *type, ...);
10 FIELDTYPE *field_type(const FIELD *field);
12 void *field_arg(const FIELD *field);
15 The function \fBset_field_type\fR declares a data type for a given form field.
16 This is the type checked by validation functions. The types are as follows:
19 Alphanumeric data. Requires a third \fBint\fR argument, a minimum field width.
22 Character data. Requires a third \fBint\fR argument, a minimum field width.
25 Accept one of a specified set of strings. Requires a third \fB(char **)\fR
26 argument pointing to a string list; a fourth \fBint\fR flag argument to enable
27 case-sensitivity; and a fifth \fBint\fR flag argument specifying whether a partial
28 match must be a unique one (if this flag is off, a prefix matches the first
29 of any set of more than one list elements with that prefix). Please notice
30 that the string list is not copied, only a reference to it is stored in the
31 field. So you should avoid to use a list that lives in automatic variables
35 Integer data, parsable to an integer by \fBatoi(3)\fR. Requires a third
36 \fBint\fR argument controlling the precision, a fourth \fBlong\fR argument
37 constraining minimum value, and a fifth \fBlong\fR constraining maximum value.
38 If the maximum value is less or equal the minimum value, the range is simply
39 ignored. On return the field buffer is formatted according to the \fBprintf\fR
40 format specification ".*ld", where the '*' is replaced by the precision argument.
41 For details of the precision handling see \fBprintf's\fR man-page.
44 Numeric data (may have a decimal-point part). Requires a third
45 \fBint\fR argument controlling the precision, a fourth \fBdouble\fR
46 argument constraining minimum value, and a fifth \fBdouble\fR constraining
47 maximum value. If your system supports locale's, the decimal point character
48 to be used must be the one specified by your locale.
49 If the maximum value is less or equal the minimum value, the range is simply
50 ignored. On return the field buffer is formatted according to the \fBprintf\fR
51 format specification ".*f", where the '*' is replaced by the precision argument.
52 For details of the precision handling see \fBprintf's\fR man-page.
55 Regular expression data. Requires a regular expression \fB(char *)\fR third argument;
56 the data is valid if the regular expression matches it. Regular expressions
57 are in the format of \fBregcomp\fR(3x) and \fBregexec\fR(3X). Please notice
58 that the regular expression must match the whole field. If you have for
59 example an eight character wide field, a regular expression "^[0-9]*$" always
60 means that you have to fill all eight positions with digits. If you want to
61 allow fewer digits, you may use for example "^[0-9]* *$" which is good for
62 trailing spaces (up to an empty field), or "^ *[0-9]* *$" which is good for
63 leading and trailing spaces around the digits.
66 An Internet Protocol Version 4 address. This requires no additional argument. It
67 is checked whether or not the buffer has the form a.b.c.d, where a,b,c and d are
68 numbers between 0 and 255. Trailing blanks in the buffer are ignored. The address
69 itself is not validated. Please note that this is an ncurses extension. This
70 field type may not be available in other curses implementations.
72 It is possible to set up new programmer-defined field types. See the
73 \fBform_fieldtype\fR(3X) manual page.
75 The functions \fBfield_type\fR and \fBfield_arg\fR return \fBNULL\fR on
76 error. The function \fBset_field_type\fR returns one of the following:
79 The routine succeeded.
82 System error occurred (see \fBerrno\fR).
84 \fBcurses\fR(3X), \fBform\fR(3X).
86 The header file \fB<form.h>\fR automatically includes the header file
89 These routines emulate the System V forms library. They were not supported on
90 Version 7 or BSD versions.
92 Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
95 .\"# The following sets edit modes for GNU EMACS