form_field_validation()

NAME

set_field_type(), field_type(), field_arg() - data type validation for fields

SYNOPSIS

#include <form.h>

int set_field_type(FIELD *field, FIELDTYPE *type, ...); FIELDTYPE *field_type(FIELD *field); char *field_arg(FIELD *field);

DESCRIPTION

The function set_field_type(3) declares a data type for a given form field. This is the type checked by validation functions. The types are as follows:

TYPE_ALNUM
Alphanumeric data. Requires a third argument, a minimum field width.
TYPE_ALPHA
Character data. Requires a third argument, a minimum field width.
TYPE_ENUM
Accept one of a specified set of strings. Requires a third (char **) argument pointing to a string list; a fourth flag argument to enable case-sensitivity; and a fifth flag argument specifying whether a partial match must be a unique one (if this flag is off, a prefix matches the first of any set of more than one list elements with that prefix).
TYPE_INTEGER
Integer data, parseable to an integer by atoi(3). Requires a third integer precision argument that sets zero-padding, a fourth argument constraining minimum value, and a fifth constraining maximum value.
TYPE_NUMERIC
Numeric data (may have a decimal-point part). Requires following arguments as for TYPE_INTEGER data.
TYPE_REGEXP
Regular expression data. Requires a regular expression third argument; the data is valid if the regular expression matches it. Regular expressions are in the format of regcomp(3) and regexec(3)

It is possible to set up new programmer-defined field types. See the form_fieldtype(3) manual page.

RETURN VALUE

The functions field_type(3) and field_arg(3) return NULL on error. The function set_field_type(3) returns one of the following:

E_OK
The routine succeeded.
E_SYSTEM_ERROR
System error occurred (see errno

SEE ALSO

atoi(3)

curses(3)

forms(3)

form_fieldtype(3)

regcomp(3)

regexec(3)

NOTES

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

PORTABILITY

These routines emulate the System V forms library. They were not supported on Version 7 or BSD versions.