Skip to main content

About StandardValidators

Class nifi.properties.StandardValidators

When defining a PropertyDescriptor, developers may choose to provide a list of validators in order to force a specific format on the user-provided value.

Attributes

NameDescription
ALWAYS_VALIDAny input value is acceptable and valid for the property
NON_EMPTY_VALIDATORValue is not empty, i.e., it contains at least one character
NON_EMPTY_EL_VALIDATORValue is both non-empty and a valid Expression Language expression
BOOLEAN_VALIDATORValue must be a valid boolean

The input must be one of the following case-insensitive values: true or false
INTEGER_VALIDATORValue must be a valid signed integer
NON_NEGATIVE_INTEGER_VALIDATORValue must be a valid unsigned integer. Can be 0
POSITIVE_INTEGER_VALIDATORValue must be a valid unsigned integer and must be grater than 0
LONG_VALIDATORValue must be a valid signed long integer
POSITIVE_LONG_VALIDATORValue must be a valid unsigned long integer and must be greater than 0
NUMBER_VALIDATORValue must be a valid numeric value, including integers and floating-point numbers
TIME_PERIOD_VALIDATORValue must represent a valid time unit;

See TIME_PERIOD_VALIDATOR
DATA_SIZE_VALIDATORValue must represent a valid data size;

See DATA_SIZE_VALIDATOR
FILE_EXISTS_VALIDATORValue must be a valid path and the file must exists in the file system
URL_VALIDATORValue must be a valid URL
URI_VALIDATORValue must be a valid URI
REGULAR_EXPRESSION_VALIDATORValue must be a valid RegEx pattern
REGULAR_EXPRESSION_WITH_EL_VALIDATORValue must be a valid RegEx pattern;

Value can include NiFi Expression Language
PORT_VALIDATORValue must be a valid network port number;

A valid range is 1 to 65535
HOSTNAME_PORT_LIST_VALIDATORValue must be a comma-separated list of hostnames and ports;

Each entry should be in the format hostname:port, separated by commas;

e.g.: localhost:8080, example.com:80, 192.168.1.1:443

e.g.:

from nifiapi.properties import PropertyDescriptor, StandardValidators


PROPERTY = PropertyDescriptor(
name="A Boolean Property",
description='''
Value of this property must be a boolean.
''',
requiered=True,
default_value=True,
validators=[
StandardValidators.BOOLEAN_VALIDATOR
]
)

TIME_PERIOD_VALIDATOR

NiFi offers a build-in TIME_PERIOD_VALIDATOR validator to ease time-based configurations, such as scheduling intervals, timeout duration, or delay periods.

tip

See how to convert a validated time period into the desired time unit here.

The time period is specified in a format that combines a numeric value with a time unit. Allowed time units are:

  • Nanoseconds: ns, nano, nanos, nanosecond or nanoseconds
  • Milliseconds: ms, milli, millis, millisecond or milliseconds
  • Seconds: s, sec, secs, second or seconds
  • Minutes: m, min, mins, minute or minutes
  • Hours: h, hr, hrs, hour or hours
  • Days: d, day or days
  • Weeks: w, wk, wks, week or weeks

For example, valid time periods might be 30 millis, 5 s, 10 minutes, 2 hrs, or 1 day.

DATA_SIZE_VALIDATOR

NiFi offers a build-in DATA_SIZE_VALIDATOR validator which ensures that a given input string conforms to a valid data size format. This is comes in handy when configuring processors that require settings such as buffer sizes, file sizes, or memory limits.

tip

See how to convert a validated data size into the desired size unit here.

The data size is specified in a format that combines a numeric value with a data size unit. Allowed units are:

  • Bytes: B
  • Kilobytes: KB
  • Megabytes: MB
  • Gigabytes: GB
  • Terabytes: TB

For example, valid data sizes might be 512 B, 10 KB, 256 MB, 1 GB, or 2 TB.