You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@isis.apache.org by Minto van der Sluis <mi...@xup.nl> on 2013/02/02 16:29:56 UTC
Field validation on getters?
Hi Folks,
In the quickstart ToDo application I just noticed the following:
@RegEx( validation = "\\w[@&:\\-\\,\\.\\+ \\w]*" )
// words, spaces and selected punctuation
@MemberOrder( sequence = "2" )
public String getDescription() {
...
To me it seems like validation is specified on the getter method. Is
this correct? Shouldn't this be specified on the setter or the member
field instead?
Regards,
Minto
Re: Field validation on getters?
Posted by Minto van der Sluis <mi...@xup.nl>.
Hi Dan,
I just created ISIS-325
Regards,
Minto
Op 3-2-2013 16:04, Dan Haywood schreef:
> On 2 February 2013 15:29, Minto van der Sluis <mi...@xup.nl> wrote:
>
>> Hi Folks,
>>
>> In the quickstart ToDo application I just noticed the following:
>>
>> @RegEx( validation = "\\w[@&:\\-\\,\\.\\+ \\w]*" )
>> // words, spaces and selected punctuation
>> @MemberOrder( sequence = "2" )
>> public String getDescription() {
>> ...
>>
>> To me it seems like validation is specified on the getter method. Is
>> this correct? Shouldn't this be specified on the setter or the member
>> field instead?
>>
> I agree that it might seem a bit confusing, but at the moment all the
> FacetFactory's only ever read the getter method for properties.
>
> I don't see anything in principal for extending the FacetFactory's to also
> look at fields and setters; in this particular case I could well imagine
> that someone might expect the annotation to live on the setter. The same
> is true for annotations such as @MaxLength.
>
> Another benefit of having the FacetFactory's look at the fields is that
> then Lombok [1] could be configured. This would save a lot of boilerplate,
> as I know you know.
>
> Making the change is relative straightforward, it's just a matter of doing
> a lot "grunt" work to quite a lot of existing FacetFactory's. I wouldn't
> have any objection to applying any patches received, though.
>
> And if you want to raise a ticket for this idea, please go ahead.
>
> Cheers
> Dan
>
> [1] http://projectlombok.org/
>
>
>
>> Regards,
>>
>> Minto
>>
--
ir. ing. Minto van der Sluis
Software innovator / renovator
Xup BV
Mobiel: +31 (0) 626 014541
Re: Field validation on getters?
Posted by Dan Haywood <da...@haywood-associates.co.uk>.
On 2 February 2013 15:29, Minto van der Sluis <mi...@xup.nl> wrote:
> Hi Folks,
>
> In the quickstart ToDo application I just noticed the following:
>
> @RegEx( validation = "\\w[@&:\\-\\,\\.\\+ \\w]*" )
> // words, spaces and selected punctuation
> @MemberOrder( sequence = "2" )
> public String getDescription() {
> ...
>
> To me it seems like validation is specified on the getter method. Is
> this correct? Shouldn't this be specified on the setter or the member
> field instead?
>
I agree that it might seem a bit confusing, but at the moment all the
FacetFactory's only ever read the getter method for properties.
I don't see anything in principal for extending the FacetFactory's to also
look at fields and setters; in this particular case I could well imagine
that someone might expect the annotation to live on the setter. The same
is true for annotations such as @MaxLength.
Another benefit of having the FacetFactory's look at the fields is that
then Lombok [1] could be configured. This would save a lot of boilerplate,
as I know you know.
Making the change is relative straightforward, it's just a matter of doing
a lot "grunt" work to quite a lot of existing FacetFactory's. I wouldn't
have any objection to applying any patches received, though.
And if you want to raise a ticket for this idea, please go ahead.
Cheers
Dan
[1] http://projectlombok.org/
>
> Regards,
>
> Minto
>