NIFI-15674: Add isValidDate and isValidInstant Expression Language fu…#10975
Open
Scrooge-McDucks wants to merge 1 commit intoapache:mainfrom
Open
NIFI-15674: Add isValidDate and isValidInstant Expression Language fu…#10975Scrooge-McDucks wants to merge 1 commit intoapache:mainfrom
Scrooge-McDucks wants to merge 1 commit intoapache:mainfrom
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
UpdateAttributeorRouteOnAttributeto guard parsing. Regex can validate shape, but it is not calendar-aware, so values like31-02-2026may 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
trueif the subject can be parsed as a valid date using the supplied format, otherwisefalse.isValidDate(format, timezone)Returns
trueif the subject can be parsed as a valid date using the supplied format and timezone, otherwisefalse.isValidInstant()Returns
trueif the subject can be parsed as a valid ISO-8601 instant, otherwisefalse.Invalid input returns
falserather 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
NIFI-00000NIFI-00000VerifiedstatusPull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
./mvnw clean install -P contrib-checkLicensing
LICENSEandNOTICEfilesDocumentation