You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by Russell Bateman <ru...@perfectsearchcorp.com> on 2016/05/12 17:25:42 UTC

Required, either-or properties

How are folk specifying processor properties in the case where one of 
two properties is required, but not both? I'm just wondering if there's 
a best practice here or must I say something in the description?

For example, I've written a processor that implements Apache Velocity 
templating. I require the template content be passed either directly as 
the value of a property, "Template content", or a filesystem path to 
this content in a property, "Template filepath".


Re: Required, either-or properties

Posted by Russell Bateman <ru...@perfectsearchcorp.com>.
We'll make it work!

Thanks.

On Thu, May 12, 2016 at 11:56 AM, Joe Witt <jo...@gmail.com> wrote:

> Russ,
>
> Yeah - I recommend you mark them both optional then use customValidate
> to check for 'should never happen cases' and then provide validation
> errors for this scenarios which explain to the user proper handling.
> You can also use the PropertyDescriptor of each property to explain
> its intended relationship to other properties.
>
> Does that seem like it will take care of your case?
>
> Thanks
> Joe
>
> On Thu, May 12, 2016 at 1:35 PM, Russell Bateman
> <ru...@perfectsearchcorp.com> wrote:
> > Joe,
> >
> > Thanks for your reply.
> >
> > As I'm thinking about it, validation of the property value isn't so much
> my
> > problem. It's documentation.
> >
> > If I mark the property documentation for both properties as required,
> then
> > my consumer will wonder what supplying both would mean. However, one of
> the
> > two, but never both is required. If both are supplied (whatever that
> would
> > mean in the mind of the consumer), I ignore the template on the
> filesystem
> > path since I check for the existence of the direct content property
> first.
> >
> > Is this dilemma a candidate for the /customValidate/ method you mention?
> >
> > Best,
> > Russ
> >
> >
> > On 05/12/2016 11:28 AM, Joe Witt wrote:
> >>
> >> Russell,
> >>
> >> Validators on property descriptors help with validating that property
> >> alone.  But in the processor API there is 'customValidate' method you
> >> can implement which is used to do things like compound/conditional
> >> validation.
> >>
> >> Thanks
> >> Joe
> >>
> >> On Thu, May 12, 2016 at 1:25 PM, Russell Bateman
> >> <ru...@perfectsearchcorp.com> wrote:
> >>>
> >>> How are folk specifying processor properties in the case where one of
> two
> >>> properties is required, but not both? I'm just wondering if there's a
> >>> best
> >>> practice here or must I say something in the description?
> >>>
> >>> For example, I've written a processor that implements Apache Velocity
> >>> templating. I require the template content be passed either directly as
> >>> the
> >>> value of a property, "Template content", or a filesystem path to this
> >>> content in a property, "Template filepath".
> >>>
> >
>

Re: Required, either-or properties

Posted by Joe Witt <jo...@gmail.com>.
Russ,

Yeah - I recommend you mark them both optional then use customValidate
to check for 'should never happen cases' and then provide validation
errors for this scenarios which explain to the user proper handling.
You can also use the PropertyDescriptor of each property to explain
its intended relationship to other properties.

Does that seem like it will take care of your case?

Thanks
Joe

On Thu, May 12, 2016 at 1:35 PM, Russell Bateman
<ru...@perfectsearchcorp.com> wrote:
> Joe,
>
> Thanks for your reply.
>
> As I'm thinking about it, validation of the property value isn't so much my
> problem. It's documentation.
>
> If I mark the property documentation for both properties as required, then
> my consumer will wonder what supplying both would mean. However, one of the
> two, but never both is required. If both are supplied (whatever that would
> mean in the mind of the consumer), I ignore the template on the filesystem
> path since I check for the existence of the direct content property first.
>
> Is this dilemma a candidate for the /customValidate/ method you mention?
>
> Best,
> Russ
>
>
> On 05/12/2016 11:28 AM, Joe Witt wrote:
>>
>> Russell,
>>
>> Validators on property descriptors help with validating that property
>> alone.  But in the processor API there is 'customValidate' method you
>> can implement which is used to do things like compound/conditional
>> validation.
>>
>> Thanks
>> Joe
>>
>> On Thu, May 12, 2016 at 1:25 PM, Russell Bateman
>> <ru...@perfectsearchcorp.com> wrote:
>>>
>>> How are folk specifying processor properties in the case where one of two
>>> properties is required, but not both? I'm just wondering if there's a
>>> best
>>> practice here or must I say something in the description?
>>>
>>> For example, I've written a processor that implements Apache Velocity
>>> templating. I require the template content be passed either directly as
>>> the
>>> value of a property, "Template content", or a filesystem path to this
>>> content in a property, "Template filepath".
>>>
>

Re: Required, either-or properties

Posted by Russell Bateman <ru...@perfectsearchcorp.com>.
Joe,

Thanks for your reply.

As I'm thinking about it, validation of the property value isn't so much 
my problem. It's documentation.

If I mark the property documentation for both properties as required, 
then my consumer will wonder what supplying both would mean. However, 
one of the two, but never both is required. If both are supplied 
(whatever that would mean in the mind of the consumer), I ignore the 
template on the filesystem path since I check for the existence of the 
direct content property first.

Is this dilemma a candidate for the /customValidate/ method you mention?

Best,
Russ

On 05/12/2016 11:28 AM, Joe Witt wrote:
> Russell,
>
> Validators on property descriptors help with validating that property
> alone.  But in the processor API there is 'customValidate' method you
> can implement which is used to do things like compound/conditional
> validation.
>
> Thanks
> Joe
>
> On Thu, May 12, 2016 at 1:25 PM, Russell Bateman
> <ru...@perfectsearchcorp.com> wrote:
>> How are folk specifying processor properties in the case where one of two
>> properties is required, but not both? I'm just wondering if there's a best
>> practice here or must I say something in the description?
>>
>> For example, I've written a processor that implements Apache Velocity
>> templating. I require the template content be passed either directly as the
>> value of a property, "Template content", or a filesystem path to this
>> content in a property, "Template filepath".
>>


Re: Required, either-or properties

Posted by Joe Witt <jo...@gmail.com>.
Russell,

Validators on property descriptors help with validating that property
alone.  But in the processor API there is 'customValidate' method you
can implement which is used to do things like compound/conditional
validation.

Thanks
Joe

On Thu, May 12, 2016 at 1:25 PM, Russell Bateman
<ru...@perfectsearchcorp.com> wrote:
> How are folk specifying processor properties in the case where one of two
> properties is required, but not both? I'm just wondering if there's a best
> practice here or must I say something in the description?
>
> For example, I've written a processor that implements Apache Velocity
> templating. I require the template content be passed either directly as the
> value of a property, "Template content", or a filesystem path to this
> content in a property, "Template filepath".
>