Skip to content

NIFI-15674: Add isValidDate and isValidInstant Expression Language fu…#10975

Open
Scrooge-McDucks wants to merge 1 commit intoapache:mainfrom
Scrooge-McDucks:NIFI-15674
Open

NIFI-15674: Add isValidDate and isValidInstant Expression Language fu…#10975
Scrooge-McDucks wants to merge 1 commit intoapache:mainfrom
Scrooge-McDucks:NIFI-15674

Conversation

@Scrooge-McDucks
Copy link
Contributor

Summary

NIFI-15674

Adds two new Expression Language validation functions:

  • isValidDate(format[, timezone])
  • isValidInstant()

These functions allow flows to validate date and instant values before attempting conversion.

Motivation

NiFi currently does not provide a simple top-level Expression Language function for validating whether a value can be parsed as a date or instant.

Today, users often need to rely on regex, nested expressions, or extra processor logic in places like UpdateAttribute or RouteOnAttribute to guard parsing. Regex can validate shape, but it is not calendar-aware, so values like 31-02-2026 may still appear valid even though they are not real dates.

This also creates operational risk. If invalid values are parsed directly, expression evaluation can fail, which in some flows can lead to repeated retries or queue looping instead of clean handling.

These functions provide a lightweight and safe way to keep validation logic visible at the top level of an expression.

Behavior

isValidDate(format)

Returns true if the subject can be parsed as a valid date using the supplied format, otherwise false.

isValidDate(format, timezone)

Returns true if the subject can be parsed as a valid date using the supplied format and timezone, otherwise false.

isValidInstant()

Returns true if the subject can be parsed as a valid ISO-8601 instant, otherwise false.

Invalid input returns false rather than throwing an evaluation error.

Examples

${myDate:isValidDate("dd-MM-yyyy"):ifElse("valid","invalid")}

${myDate:isValidDate("yyyy-MM-dd HH:mm:ss", "UTC")}

${eventTime:isValidInstant():ifElse("valid-instant","invalid-instant")}

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000
  • Pull request contains commits signed with a registered key indicating Verified status

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using ./mvnw clean install -P contrib-check
    • JDK 21
    • JDK 25

Licensing

  • New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

…nctions

- Added `isValidInstant()` for safe validation of ISO-8601 instants and RFC-1123 date-time values
- Added `isValidDate(format[, timezone])` for calendar-aware date validation using a `DateTimeFormatter` pattern and optional timezone
- Invalid calendar dates such as `31-02-2026` now return `false` instead of requiring parse handling downstream
- Updated ANTLR grammars, `ExpressionCompiler`, tests, and documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant