Support Questions

Find answers, ask questions, and share your expertise
Celebrating as our community reaches 100,000 members! Thank you!

GenerateFlowFile Validations




     I am using GenerateFlowFile processor to pass month and year information.

     The format in which we are passing custom text in GenerateFlowFile is as follows:



    Our requirement is, if user enters month and year information it has to be validated.

    For example, he has to provide valid information like may,2023 but apart from this if he provides      any other invalid information other than month and year attributes it has to through error.

   How can we achieve such constraints or validation?


Thank you!


Super Mentor


There seems to be a lot of missing details needed from your use case description.
The GenerateFlowFile processor is used to create a FlowFile (it can be configured to produce a FlowFile with specific content and specific custom FlowFile Attributes as well).

So from your use case description, you are adding custom text to your GenerateFlowFile processor and want to validate that the custom added text is correct later in your dataflow?  Biot confused on the validation since you are defining the format in the GenerateFlowFile.  Where do you expect that text to get changed in your dataflow(s) thus requiring your to validate it?

I am not clear on yoru end-to-end use case.

Processors like the following can be used to validate FlowFiles:
1) RouteOnAttribute - could be used to evaluate a NiFi Expression Language (NEL) against the value of an attribute on a FlowFile and the route to a dynamic relationship.  That dynamic failure relationship or unmatched relationship depending on your choice of implementation could be passed to an updateAttribute processor where you generate the log exception text.  Then route to a logAttribute processor that could be configured to produce an ERROR log output line to the nifi-app.log reporting your exception.
2. RouteOnContent - Similar strategy as RouteOnAttribute except here you create dynamic properties that use java regular expressions that are evaluated against the FlowFIle's content instead of a FlowFile's attribute to route FlowFiles to a dynamic relationship. rest of dataflow design is same as above.


If you found that the provided solution(s) assisted you with your query, please take a moment to login and click Accept as Solution below each response that helped.

Thank you,