wiki:Doc/panc/stdtpl/types

pan/types Template

Machine configuration often need type definitions for things like host names, URLs, port numbers and the like. These occur in most machine configuration and the associated type definitions have been provided in the 'pan/types' template. You can use these types by including this template in your machine configuraton:

  include { 'pan/types' };

Each of the defined types has an associated validation function that can be used in the construction of other types. The sections below give the name of the type and the associated validation function.

Date-Related Types

type_asndate, is_asndate(string)

This type implements a date/time format consistent with ASN.1 typically used by LDAP. The actual specification is the "GeneralizedTime" format as specified on page 38 of the X.208 ITU-T recommendation and references within. Examples include:

20040825120123Z
20040825120123+0100
20040825120123,5
20040825120123.5
20040825120123.5-0123

type_isodate, is_isodate(string)

This type implements a date/time format consistent with the W3C use of the datetime format. (See the document][http://www.w3.org/TR/NOTE-datetime?.) This is a subset of the ISO8601 specification. This type allows a short form with just a complete date or a full date/time. For the time (if given) only the fractions of a second field is optional. Examples include:

2004-08-25
2004-08-25T12:32:00.01+05:00
2004-08-25T12:32:00Z

Network-Related Types

type_hwaddr, is_hwaddr(string)

The hardware address is a series of six bytes encoded as hex values and separated with a colon or a hyphen. Within a value you must use a consistent separator. Both upper and lower-case hex digits are accepted. Examples:

00:D0:59:33:F6:30
00-D0-59-33-F6-30

type_ipv4, is_ipv4(string)

IPv4 address in dotted-decimal notation. Examples:

127.0.0.1
208.77.188.166

type_ipv6, is_ipv6(string)

IPv6 address in usual notation with colon-separated fields.

type_ip, is_ip(string)

A value that is either a valid IPv4 or IPv6 network address.

type_network_name, is_network_name(string)

A value that is either a valid host name (with domain), IP address, has the form ".domain", or the form "IP/mask".

Hostname-Related Types

type_fqdn, is_fqdn(string)

A fully-qualified domain name. Each part of the domain name is separated by a period. The individual parts must begin with a letter or digit, end with a letter or digit, and may contain letters, digits, or hyphens in the middle. The relevant RFC's for host name syntax are 952, 1053, and 1123 (section 2.1).

type_hostname, is_hostname(string)

Values that are either a valid raw IP address (v4 or v6) or a fully-qualified domain name.

type_shorthostname, is_shorthostname(string)

A string that is a valid name for a host and that does not contain the domain.

type_port, is_port(long)

A long value that is a valid port number (i.e. in the range [0, 65535]).

type_hostport, is_hostport(string)

A value of the form "hostname:port". The individual component are verified to be also correct.

Web and Email Types

type_URI, is_URI(string)

This defines an URI according to RFC2396. Note that this is the most general URI which allows opaque URIs, hostbased URIs, and relative URIs. You may want a more specific-type for a particular value.

type_absoluteURI, is_absoluteURI(string)

This defines an absolute URI according to RFC2396. This is just a valid URI with the scheme explicitly included.

type_hostURI, is_hostURI(string)

This defines an URI according to RFC2396. A host-based URI is an absolute URI with a non-empty host field.

type_email, is_email(string)

Defines a valid email address; both the receipient and domain must be specified.

Miscellaneous

type_lowercase, is_lowercase(string)

Returns false if the string contains any of the characters A-Z; returns true otherwise.

type_uppercase, is_uppercase(string)

Returns false if the string contains any of the characters a-z; returns true otherwise.

Last modified 16 years ago Last modified on Nov 30, 2007, 4:05:45 PM