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
| Name | Description |
|---|---|
ALWAYS_VALID | Any input value is acceptable and valid for the property |
NON_EMPTY_VALIDATOR | Value is not empty, i.e., it contains at least one character |
NON_EMPTY_EL_VALIDATOR | Value is both non-empty and a valid Expression Language expression |
BOOLEAN_VALIDATOR | Value must be a valid boolean The input must be one of the following case-insensitive values: true or false |
INTEGER_VALIDATOR | Value must be a valid signed integer |
NON_NEGATIVE_INTEGER_VALIDATOR | Value must be a valid unsigned integer. Can be 0 |
POSITIVE_INTEGER_VALIDATOR | Value must be a valid unsigned integer and must be grater than 0 |
LONG_VALIDATOR | Value must be a valid signed long integer |
POSITIVE_LONG_VALIDATOR | Value must be a valid unsigned long integer and must be greater than 0 |
NUMBER_VALIDATOR | Value must be a valid numeric value, including integers and floating-point numbers |
TIME_PERIOD_VALIDATOR | Value must represent a valid time unit; See TIME_PERIOD_VALIDATOR |
DATA_SIZE_VALIDATOR | Value must represent a valid data size; See DATA_SIZE_VALIDATOR |
FILE_EXISTS_VALIDATOR | Value must be a valid path and the file must exists in the file system |
URL_VALIDATOR | Value must be a valid URL |
URI_VALIDATOR | Value must be a valid URI |
REGULAR_EXPRESSION_VALIDATOR | Value must be a valid RegEx pattern |
REGULAR_EXPRESSION_WITH_EL_VALIDATOR | Value must be a valid RegEx pattern; Value can include NiFi Expression Language |
PORT_VALIDATOR | Value must be a valid network port number; A valid range is 1 to 65535 |
HOSTNAME_PORT_LIST_VALIDATOR | Value 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.
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,nanosecondornanoseconds - Milliseconds:
ms,milli,millis,millisecondormilliseconds - Seconds:
s,sec,secs,secondorseconds - Minutes:
m,min,mins,minuteorminutes - Hours:
h,hr,hrs,hourorhours - Days:
d,dayordays - Weeks:
w,wk,wks,weekorweeks
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.
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.