1form_field_validation(3X)                            form_field_validation(3X)
2
3
4

NAME

6       form_field_validation - data type validation for fields
7

SYNOPSIS

9       #include <form.h>
10       int set_field_type(FIELD *field, FIELDTYPE *type, ...);
11       FIELDTYPE *field_type(const FIELD *field);
12       void *field_arg(const FIELD *field);
13
14       FIELDTYPE *TYPE_ALNUM;
15       FIELDTYPE *TYPE_ALPHA;
16       FIELDTYPE *TYPE_ENUM;
17       FIELDTYPE *TYPE_INTEGER;
18       FIELDTYPE *TYPE_NUMERIC;
19       FIELDTYPE *TYPE_REGEXP;
20       FIELDTYPE *TYPE_IPV4;
21

DESCRIPTION

23       The  function  set_field_type  declares  a  data  type for a given form
24       field.  This is the type checked by validation functions.   The  prede‐
25       fined types are as follows:
26
27       TYPE_ALNUM
28            Alphanumeric data.  Requires a third int argument, a minimum field
29            width.
30
31       TYPE_ALPHA
32            Character data.  Requires a third int argument,  a  minimum  field
33            width.
34
35       TYPE_ENUM
36            Accept  one of a specified set of strings.  Requires a third (char
37            **) argument pointing to a string list; a fourth int flag argument
38            to enable case-sensitivity; and a fifth int flag argument specify‐
39            ing whether a partial match must be a unique one (if this flag  is
40            off,  a  prefix matches the first of any set of more than one list
41            elements with that prefix). Please notice that the string list  is
42            copied. So you may use a list that lives in automatic variables on
43            the stack.
44
45       TYPE_INTEGER
46            Integer data, parsable to an integer by atoi(3).  Requires a third
47            int  argument  controlling  the  precision, a fourth long argument
48            constraining minimum value, and a fifth long constraining  maximum
49            value.   If the maximum value is less than or equal to the minimum
50            value, the range is simply ignored. On return the field buffer  is
51            formatted  according  to  the  printf format specification ".*ld",
52            where the '*' is replaced by the precision argument.  For  details
53            of the precision handling see printf's man-page.
54
55       TYPE_NUMERIC
56            Numeric data (may have a decimal-point part). Requires a third int
57            argument controlling the precision, a fourth double argument  con‐
58            straining  minimum  value, and a fifth double constraining maximum
59            value. If your system supports locales, the decimal point  charac‐
60            ter  to  be used must be the one specified by your locale.  If the
61            maximum value is less than or equal  to  the  minimum  value,  the
62            range  is  simply ignored. On return the field buffer is formatted
63            according to the printf format specification ".*f", where the  '*'
64            is  replaced by the precision argument.  For details of the preci‐
65            sion handling see printf's man-page.
66
67       TYPE_REGEXP
68            Regular expression data.  Requires a regular expression  (char  *)
69            third  argument;  the  data  is  valid  if  the regular expression
70            matches it.  Regular expressions are in the format of regcomp  and
71            regexec.  Please notice that the regular expression must match the
72            whole field. If you have  for  example  an  eight  character  wide
73            field,  a regular expression "^[0-9]*$" always means that you have
74            to fill all eight positions with digits.  If  you  want  to  allow
75            fewer  digits,  you may use for example "^[0-9]* *$" which is good
76            for trailing spaces (up to an empty  field),  or  "^  *[0-9]*  *$"
77            which is good for leading and trailing spaces around the digits.
78
79       TYPE_IPV4
80            An  Internet  Protocol  Version  4 address. This requires no addi‐
81            tional argument. It is checked whether or not the buffer  has  the
82            form  a.b.c.d,  where  a,b,c  and d are numbers between 0 and 255.
83            Trailing blanks in the buffer are ignored. The address  itself  is
84            not validated. Please note that this is an ncurses extension. This
85            field type may not be available in other curses implementations.
86
87       It is possible to set up new programmer-defined field types.   See  the
88       form_fieldtype(3X) manual page.
89

RETURN VALUE

91       The  functions field_type and field_arg return NULL on error. The func‐
92       tion set_field_type returns one of the following:
93
94       E_OK The routine succeeded.
95
96       E_SYSTEM_ERROR
97            System error occurred (see errno).
98

SEE ALSO

100       curses(3X), form(3X).
101

NOTES

103       The  header  file  <form.h>  automatically  includes  the  header  file
104       <curses.h>.
105

PORTABILITY

107       These  routines emulate the System V forms library.  They were not sup‐
108       ported on Version 7 or BSD versions.
109

AUTHORS

111       Juergen Pfeifer.  Manual pages and adaptation for new curses by Eric S.
112       Raymond.
113
114
115
116                                                     form_field_validation(3X)
Impressum