Stripes

@Validate(required=true) only applies to parameters pre-conversion

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Not a Bug
  • Affects Version/s: None
  • Fix Version/s: Release 1.6
  • Component/s: Validation
  • Labels:
    None

Description

Validation for required parameters passes when a parameter is not null and not empty even if the type converter returns null. It seems that if a property is marked with @Validate(required=true) then the type converter returning null should trigger a validation error.

Activity

Hide
Nikolaos added a comment - 11/Nov/10 1:31 PM

I think this is a pretty significant issue... just b/c a value is supplied does not mean that the value is adequate from a type conversion perspective. Shouldn't we address this in 1.5.x?

--Nikolaos

Show
Nikolaos added a comment - 11/Nov/10 1:31 PM I think this is a pretty significant issue... just b/c a value is supplied does not mean that the value is adequate from a type conversion perspective. Shouldn't we address this in 1.5.x? --Nikolaos
Hide
Ben Gunter added a comment - 11/Nov/10 3:00 PM

It has behaved this way for years. I don't want to alter this kind of behavior for a minor release.

Show
Ben Gunter added a comment - 11/Nov/10 3:00 PM It has behaved this way for years. I don't want to alter this kind of behavior for a minor release.
Hide
Frederic Daoud added a comment - 11/Nov/10 3:17 PM

> just b/c a value is supplied does not mean that the value is adequate from a type conversion perspective

True, but if the value supplied is not adequate from a type conversion perspective, the type converter should be responsible for indicating the error. The type converter does get a reference to the collection of validation errors in the convert method.

Show
Frederic Daoud added a comment - 11/Nov/10 3:17 PM > just b/c a value is supplied does not mean that the value is adequate from a type conversion perspective True, but if the value supplied is not adequate from a type conversion perspective, the type converter should be responsible for indicating the error. The type converter does get a reference to the collection of validation errors in the convert method.
Hide
Oscar Westra van Holthe - Kind added a comment - 11/Nov/10 3:33 PM

As I read it, @Validate(required=true) now checks if the user provided anything, which is exactly what I expect for a required field.

I suspect it has to do with my expectation that type conversion translates an empty input to null, and non-empty input to either a valid non-null value or an error.

Show
Oscar Westra van Holthe - Kind added a comment - 11/Nov/10 3:33 PM As I read it, @Validate(required=true) now checks if the user provided anything, which is exactly what I expect for a required field. I suspect it has to do with my expectation that type conversion translates an empty input to null, and non-empty input to either a valid non-null value or an error.
Hide
Nikolaos added a comment - 11/Nov/10 4:57 PM

Your correct Freddy. The type converter has the opportunity to throw an error but I don't think that was the issue.

The question is how far does "@Validate(required=true)" take you? If it goes as far as the user having provided some non-empty input as Oscar points out then everything is working as expected. And now that I think about this again I totally agree with Oscar's assessment.

So... Aaron... what do you think?

--Nikolaos

Show
Nikolaos added a comment - 11/Nov/10 4:57 PM Your correct Freddy. The type converter has the opportunity to throw an error but I don't think that was the issue. The question is how far does "@Validate(required=true)" take you? If it goes as far as the user having provided some non-empty input as Oscar points out then everything is working as expected. And now that I think about this again I totally agree with Oscar's assessment. So... Aaron... what do you think? --Nikolaos
Hide
Marcus Kraßmann added a comment - 09/Jan/11 6:41 AM

What about this: Every conversion to null results in a ValidationError if the provided input is not null. Are there possible scenarios where null would be an acceptable return value for a converter?!

Show
Marcus Kraßmann added a comment - 09/Jan/11 6:41 AM What about this: Every conversion to null results in a ValidationError if the provided input is not null. Are there possible scenarios where null would be an acceptable return value for a converter?!
Hide
Frederic Daoud added a comment - 16/Mar/11 12:59 PM

@Validate(required=true) checks for a value up front. Only if the value is not null is the type converter invoked. There are use cases where you want to return null from a type converter without a validation error. If you want a validation error, report it within the type converter.

Show
Frederic Daoud added a comment - 16/Mar/11 12:59 PM @Validate(required=true) checks for a value up front. Only if the value is not null is the type converter invoked. There are use cases where you want to return null from a type converter without a validation error. If you want a validation error, report it within the type converter.

People

Vote (0)
Watch (0)

Dates

  • Created:
    04/Jun/10 3:01 PM
    Updated:
    16/Mar/11 12:59 PM
    Resolved:
    16/Mar/11 12:59 PM