]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/form_field_validation.3x
ncurses 4.1
[ncurses.git] / man / form_field_validation.3x
1 '\" t
2 .TH form_field_validation 3X ""
3 .SH NAME
4 \fBform_field_validation\fR - data type validation for fields 
5 .SH SYNOPSIS
6 \fB#include <form.h>\fR
7 .br
8 int set_field_type(FIELD *field, FIELDTYPE *type, ...);
9 .br
10 FIELDTYPE *field_type(const FIELD *field);
11 .br
12 void *field_arg(const FIELD *field);
13 .br
14 .SH DESCRIPTION
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:
17 .TP 5
18 TYPE_ALNUM
19 Alphanumeric data.  Requires a third \fBint\fR argument, a minimum field width.
20 .TP 5
21 TYPE_ALPHA
22 Character data.  Requires a third \fBint\fR argument, a minimum field width.
23 .TP 5
24 TYPE_ENUM
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
32 on the stack.
33 .TP 5
34 TYPE_INTEGER
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.
42 .TP 5
43 TYPE_NUMERIC
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.
53 .TP 5
54 TYPE_REGEXP
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.
64 .TP 5
65 TYPE_IPV4
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.
71
72 It is possible to set up new programmer-defined field types.  See the
73 \fBform_fieldtype\fR(3X) manual page.
74 .SH RETURN VALUE
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:
77 .TP 5
78 \fBE_OK\fR
79 The routine succeeded.
80 .TP 5
81 \fBE_SYSTEM_ERROR\fR
82 System error occurred (see \fBerrno\fR).
83 .SH SEE ALSO
84 \fBcurses\fR(3X), \fBform\fR(3X).
85 .SH NOTES
86 The header file \fB<form.h>\fR automatically includes the header file
87 \fB<curses.h>\fR.
88 .SH PORTABILITY
89 These routines emulate the System V forms library.  They were not supported on
90 Version 7 or BSD versions.
91 .SH AUTHORS
92 Juergen Pfeifer.  Manual pages and adaptation for new curses by Eric
93 S. Raymond.
94 .\"#
95 .\"# The following sets edit modes for GNU EMACS
96 .\"# Local Variables:
97 .\"# mode:nroff
98 .\"# fill-column:79
99 .\"# End: