[
https://issues.apache.org/jira/browse/NIFI-15674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18068244#comment-18068244
]
ASF subversion and git services commented on NIFI-15674:
--------------------------------------------------------
Commit e44b12385411a609ecd7e58c7562f4024f846a14 in nifi's branch
refs/heads/main from Richard Scott
[ https://gitbox.apache.org/repos/asf?p=nifi.git;h=e44b1238541 ]
NIFI-15674: Add isValidDate and isValidInstant Expression Language functions
(#10975)
- isValidDate(format[, timezone]) returns true if the subject parses as
a valid calendar date using the given format and optional timezone;
rejects invalid calendar combinations (e.g. Feb 31), DST gap times,
and supports both 24-hour (HH) and 12-hour (hh a) clock formats
- isValidInstant() returns true if the subject parses as a valid
ISO-8601 instant (ISO_INSTANT, ISO_OFFSET_DATE_TIME, RFC_1123)
- Added oneOrTwoArgBool to anyArg in parser grammar so isValidDate
can appear as an argument to other functions
> Add "isValidDate" and "isValidInstant" Expression Language functions
> --------------------------------------------------------------------
>
> Key: NIFI-15674
> URL: https://issues.apache.org/jira/browse/NIFI-15674
> Project: Apache NiFi
> Issue Type: Improvement
> Components: Core Framework
> Reporter: Richard Scott
> Assignee: Richard Scott
> Priority: Minor
> Fix For: 2.8.0
>
> Time Spent: 40m
> Remaining Estimate: 0h
>
> NiFi currently has no simple top-level Expression Language function to check
> whether a value is a valid date or instant before attempting to parse it.
> Today, users often need to rely on regex, advanced expressions, or extra
> processor logic in *UpdateAttribute* or *RouteOnAttribute* to validate date
> input first. Regex can help check whether a value matches the expected shape,
> but it is not calendar-aware and cannot reliably determine whether a value is
> an actual valid date. For example, a value may match {{dd-MM-yyyy}} while
> still being invalid as a real calendar date.
> This pushes validation logic into more complex or buried configurations and
> makes flows harder to read.
> It also creates operational risk. If an invalid value is parsed without first
> checking validity, the expression can fail. In some flow designs, this can
> lead to FlowFiles repeatedly retrying or looping in a queue instead of being
> cleanly handled.
> Adding {{isValidDate}} and {{isValidInstant}} would allow users to validate
> input safely and keep that logic visible at the top level of an expression.
> h2. Proposed Functions
> *{{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{}}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)