Skip to content

MINIFICPP-2862 Add StandardValidator::NUMBER_VALIDATOR#2213

Merged
martinzink merged 7 commits into
apache:api_bumpfrom
martinzink:MINIFICPP-2862
Jul 15, 2026
Merged

MINIFICPP-2862 Add StandardValidator::NUMBER_VALIDATOR#2213
martinzink merged 7 commits into
apache:api_bumpfrom
martinzink:MINIFICPP-2862

Conversation

@martinzink

Copy link
Copy Markdown
Member

Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.

In order to streamline the review of the contribution we ask you to ensure the following steps have been taken:

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?

  • Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.

  • Has your PR been rebased against the latest commit within the target branch (typically main)?

  • Is your initial contribution a single, squashed commit?

For code changes:

  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file?
  • If applicable, have you updated the NOTICE file?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

Note:

Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new standard numeric property validator to MiNiFi C++ and updates the parsing utilities to support stricter floating-point parsing via std::from_chars, then wires the validator through the C API mappings and validates behavior with unit tests.

Changes:

  • Introduces StandardPropertyValidators::NUMBER_VALIDATOR and exposes it through the C API enum/mapping.
  • Replaces parseFloat with a templated parseFloatingPoint<T> implementation using std::from_chars.
  • Adds/updates property parsing helpers and a unit test covering numeric validation.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
minifi-api/include/minifi-api.h Adds MINIFI_VALIDATOR_NUMBER to the C API validator enum.
minifi-api/common/include/minifi-cpp/core/PropertyValidator.h Adds NumberValidator and exposes it as a standard validator; refactors validator classes.
libminifi/test/unit/PropertyValidationTests.cpp Adds unit test coverage for the new number validator.
libminifi/src/minifi-api.cpp Maps the new C API enum value to the C++ standard validator instance.
extension-framework/include/utils/ProcessorConfigUtils.h Adds float parsing helpers and switches optional float parsing to parseFloatingPoint<float>.
extension-framework/cpp-extension-lib/src/utils/minifi-c-utils.cpp Adds reverse-mapping from NUMBER_VALIDATOR to MINIFI_VALIDATOR_NUMBER.
extension-framework/cpp-extension-lib/include/api/utils/ProcessorConfigUtils.h Switches optional float parsing to parseFloatingPoint<float>.
core-framework/common/src/utils/ParsingUtils.cpp Removes the old parseFloat implementation.
core-framework/common/include/utils/ParsingUtils.h Adds templated parseFloatingPoint<T> implementation using std::from_chars.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread extension-framework/include/utils/ProcessorConfigUtils.h Outdated
Comment thread minifi-api/common/include/minifi-cpp/core/PropertyValidator.h
Comment thread extension-framework/include/utils/ProcessorConfigUtils.h Outdated
const auto trimmed_input = utils::string::trim(input);
T value{};

const auto [ptr, ec] = std::from_chars(trimmed_input.data(), trimmed_input.data() + trimmed_input.size(), value);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlike other parsing functions in C++ and C libraries, std::from_chars is locale-independent, non-allocating, and non-throwing.

source: https://en.cppreference.com/cpp/utility/from_chars

@fgerlits fgerlits left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but do we want to implement NUMBER_VALIDATOR in Python, too, now that we can?

@martinzink

Copy link
Copy Markdown
Member Author

LGTM, but do we want to implement NUMBER_VALIDATOR in Python, too, now that we can?

sure, good idea add NUMBER_VALIDATOR to python

@martinzink
martinzink requested a review from fgerlits July 9, 2026 10:15
Comment on lines 92 to 93
}
gsl_FailFast();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we crash on unknown enum values, then adding another validator later can't be done without breaking API

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i hoped we can merge this in faster than the release 🤞

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could just fallback on ALWAYS_VALID, for c api extensions, the parsing happens on the extension side anyway

… but we would like to use them optionally we cant add this validator because it breaks the setting the value to "" to disable workflow
@szaszm

szaszm commented Jul 9, 2026

Copy link
Copy Markdown
Member

I think I'd rather stop breaking the API now in preparation for a release, and add this feature in a future version.

Comment thread extensions/python/pythonprocessors/nifiapi/properties.py
@martinzink
martinzink marked this pull request as draft July 9, 2026 14:49
@martinzink

Copy link
Copy Markdown
Member Author

I converted this to draft since its an API breaking change which we would like to avoid for now.
Maybe we could add this to a branch with all of these small api breaking changes, which we can rebase until we decide to pull the trigger and bump the api

@martinzink
martinzink changed the base branch from main to api_bump July 9, 2026 14:56
@martinzink
martinzink marked this pull request as ready for review July 9, 2026 14:56
@martinzink

Copy link
Copy Markdown
Member Author

I've retargeted the PR to api-bump branch, we can merge it if it comes to that then we can deal with the PRs collected there when we want to bump the api

@szaszm szaszm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for merging to the api_bump branch, I would just hold off of merging to main for now

@martinzink
martinzink merged commit e8e3298 into apache:api_bump Jul 15, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants