You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Sebastiaan van Erk (JIRA)" <ji...@apache.org> on 2007/09/27 17:43:50 UTC

[jira] Created: (WICKET-1017) POSITIVE and NEGATIVE in NumberValidator are badly named (or contain a bug)

POSITIVE and NEGATIVE in NumberValidator are badly named (or contain a bug)
---------------------------------------------------------------------------

                 Key: WICKET-1017
                 URL: https://issues.apache.org/jira/browse/WICKET-1017
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 1.3.0-beta3
            Reporter: Sebastiaan van Erk
            Priority: Minor


The POSITIVE validator is a new number validator with minimum 0.
However 0 is not positive. Therefore, the validator should be called NONNEGATIVE. That or it should not allow 0.
The validation messages (at least in Dutch) state that the number must be LARGER than 0 if I enter a negative number.
However, 0 is of course accepted.

Thus, for consistency I think it would probably be best to fix this one way or the other.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-1017) POSITIVE and NEGATIVE in NumberValidator are badly named (or contain a bug)

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12530762 ] 

Johan Compagner commented on WICKET-1017:
-----------------------------------------

'hmm
it all starts with the minimum(0) method,we do say there: 

	/**
	 * Gets a Integer minimum validator to check if a integer value is greater
	 * then the given minimum value.
	 * 
	 */
	public static NumberValidator minimum(long minimum)
	{
		return new MinimumValidator(minimum);
	}


but the check isn't   

if (value <= minimum) fail

but 

if (value < minimum) fail

now i am curious what people expect to happen.. is it including or not??

same goes for the maximum validator..
But do we change the maximum/minimum validators ?
Or what i also can do is add a param to the constructors of those with an including flag..
By default it stays what it is now except for the Positive and Negative onces.


Or we can always just say in  a wicket world the 0 is negative and positive!

> POSITIVE and NEGATIVE in NumberValidator are badly named (or contain a bug)
> ---------------------------------------------------------------------------
>
>                 Key: WICKET-1017
>                 URL: https://issues.apache.org/jira/browse/WICKET-1017
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.0-beta3
>            Reporter: Sebastiaan van Erk
>            Priority: Minor
>
> The POSITIVE validator is a new number validator with minimum 0.
> However 0 is not positive. Therefore, the validator should be called NONNEGATIVE. That or it should not allow 0.
> The validation messages (at least in Dutch) state that the number must be LARGER than 0 if I enter a negative number.
> However, 0 is of course accepted.
> Thus, for consistency I think it would probably be best to fix this one way or the other.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (WICKET-1017) POSITIVE and NEGATIVE in NumberValidator are badly named (or contain a bug)

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Johan Compagner closed WICKET-1017.
-----------------------------------

    Resolution: Fixed

this works to

/**
	 * a validator for ensuring for a positive number value
	 */
	public static final NumberValidator POSITIVE = minimum(Double.MIN_VALUE);

	/**
	 * a validator for ensuring a negative number value
	 */
	public static final NumberValidator NEGATIVE = maximum(-Double.MIN_VALUE);

But maybe seb can shoot a hole in this. But my added unit test say it works!

I added numerous unit test on the way for the NumberValidator classes. So we have even a better coverage!

> POSITIVE and NEGATIVE in NumberValidator are badly named (or contain a bug)
> ---------------------------------------------------------------------------
>
>                 Key: WICKET-1017
>                 URL: https://issues.apache.org/jira/browse/WICKET-1017
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.0-beta3
>            Reporter: Sebastiaan van Erk
>            Assignee: Johan Compagner
>            Priority: Minor
>             Fix For: 1.3.0-rc3
>
>
> The POSITIVE validator is a new number validator with minimum 0.
> However 0 is not positive. Therefore, the validator should be called NONNEGATIVE. That or it should not allow 0.
> The validation messages (at least in Dutch) state that the number must be LARGER than 0 if I enter a negative number.
> However, 0 is of course accepted.
> Thus, for consistency I think it would probably be best to fix this one way or the other.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-1017) POSITIVE and NEGATIVE in NumberValidator are badly named (or contain a bug)

Posted by "Sebastiaan van Erk (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12552780 ] 

Sebastiaan van Erk commented on WICKET-1017:
--------------------------------------------

By the way, the javadoc for the minimum and maximum validators are still not updated (and incorrect). They need to be precise as to whether or not the endpoints are included.

For example:

		 * Gets a Double maximum validator for checking if an number is smaller than the given maximum

Should read "is at most" or "smaller than or equal to". Same with the other validators (including the range validators).




> POSITIVE and NEGATIVE in NumberValidator are badly named (or contain a bug)
> ---------------------------------------------------------------------------
>
>                 Key: WICKET-1017
>                 URL: https://issues.apache.org/jira/browse/WICKET-1017
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.0-beta3
>            Reporter: Sebastiaan van Erk
>            Assignee: Johan Compagner
>            Priority: Minor
>             Fix For: 1.3.0-rc3
>
>
> The POSITIVE validator is a new number validator with minimum 0.
> However 0 is not positive. Therefore, the validator should be called NONNEGATIVE. That or it should not allow 0.
> The validation messages (at least in Dutch) state that the number must be LARGER than 0 if I enter a negative number.
> However, 0 is of course accepted.
> Thus, for consistency I think it would probably be best to fix this one way or the other.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WICKET-1017) POSITIVE and NEGATIVE in NumberValidator are badly named (or contain a bug)

Posted by "Frank Bille Jensen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Frank Bille Jensen updated WICKET-1017:
---------------------------------------

    Fix Version/s:     (was: 1.3.0-rc3)
                   1.3.0-final

> POSITIVE and NEGATIVE in NumberValidator are badly named (or contain a bug)
> ---------------------------------------------------------------------------
>
>                 Key: WICKET-1017
>                 URL: https://issues.apache.org/jira/browse/WICKET-1017
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.0-beta3
>            Reporter: Sebastiaan van Erk
>            Assignee: Johan Compagner
>            Priority: Minor
>             Fix For: 1.3.0-final
>
>
> The POSITIVE validator is a new number validator with minimum 0.
> However 0 is not positive. Therefore, the validator should be called NONNEGATIVE. That or it should not allow 0.
> The validation messages (at least in Dutch) state that the number must be LARGER than 0 if I enter a negative number.
> However, 0 is of course accepted.
> Thus, for consistency I think it would probably be best to fix this one way or the other.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-1017) POSITIVE and NEGATIVE in NumberValidator are badly named (or contain a bug)

Posted by "Sebastiaan van Erk (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12530775 ] 

Sebastiaan van Erk commented on WICKET-1017:
--------------------------------------------

The minimum validator is correct. If the value is STRICTLY LESS than the minimum, you should fail, and only then. It seems to me the javadoc is wrong there. It should read something like "check if an integer value is at least the given minimum value".

As far as POSITIVE being a minimum(0) validator, that seems incorrect to me. And I'd prefer it if the Wicket world didn't have it's own version of mathematics. ;-)

The "inclusive" flag seems useful to me, but then the naming is a bit unintuitive in my opinion.



> POSITIVE and NEGATIVE in NumberValidator are badly named (or contain a bug)
> ---------------------------------------------------------------------------
>
>                 Key: WICKET-1017
>                 URL: https://issues.apache.org/jira/browse/WICKET-1017
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.0-beta3
>            Reporter: Sebastiaan van Erk
>            Priority: Minor
>
> The POSITIVE validator is a new number validator with minimum 0.
> However 0 is not positive. Therefore, the validator should be called NONNEGATIVE. That or it should not allow 0.
> The validation messages (at least in Dutch) state that the number must be LARGER than 0 if I enter a negative number.
> However, 0 is of course accepted.
> Thus, for consistency I think it would probably be best to fix this one way or the other.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WICKET-1017) POSITIVE and NEGATIVE in NumberValidator are badly named (or contain a bug)

Posted by "Frank Bille Jensen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Frank Bille Jensen updated WICKET-1017:
---------------------------------------

    Fix Version/s:     (was: 1.3.0-rc2)
                   1.3.0-rc3

> POSITIVE and NEGATIVE in NumberValidator are badly named (or contain a bug)
> ---------------------------------------------------------------------------
>
>                 Key: WICKET-1017
>                 URL: https://issues.apache.org/jira/browse/WICKET-1017
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.0-beta3
>            Reporter: Sebastiaan van Erk
>            Priority: Minor
>             Fix For: 1.3.0-rc3
>
>
> The POSITIVE validator is a new number validator with minimum 0.
> However 0 is not positive. Therefore, the validator should be called NONNEGATIVE. That or it should not allow 0.
> The validation messages (at least in Dutch) state that the number must be LARGER than 0 if I enter a negative number.
> However, 0 is of course accepted.
> Thus, for consistency I think it would probably be best to fix this one way or the other.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (WICKET-1017) POSITIVE and NEGATIVE in NumberValidator are badly named (or contain a bug)

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Igor Vaynberg reassigned WICKET-1017:
-------------------------------------

    Assignee: Johan Compagner

imho parameters should always be INCLUSIVE. so range (3,5) should accept 3,4,5. minumum(0) should accept 0,1,2,...

why do we even have POSITIVE and NEGATIVE? obviously it is rather ambiguous. lets deprecate those. i mean does it really save that much having them as global instances? they still get serialized the same...

> POSITIVE and NEGATIVE in NumberValidator are badly named (or contain a bug)
> ---------------------------------------------------------------------------
>
>                 Key: WICKET-1017
>                 URL: https://issues.apache.org/jira/browse/WICKET-1017
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.0-beta3
>            Reporter: Sebastiaan van Erk
>            Assignee: Johan Compagner
>            Priority: Minor
>             Fix For: 1.3.0-rc3
>
>
> The POSITIVE validator is a new number validator with minimum 0.
> However 0 is not positive. Therefore, the validator should be called NONNEGATIVE. That or it should not allow 0.
> The validation messages (at least in Dutch) state that the number must be LARGER than 0 if I enter a negative number.
> However, 0 is of course accepted.
> Thus, for consistency I think it would probably be best to fix this one way or the other.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WICKET-1017) POSITIVE and NEGATIVE in NumberValidator are badly named (or contain a bug)

Posted by "Frank Bille Jensen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Frank Bille Jensen updated WICKET-1017:
---------------------------------------

    Fix Version/s:     (was: 1.3.0-rc1)
                   1.3.0-rc2

> POSITIVE and NEGATIVE in NumberValidator are badly named (or contain a bug)
> ---------------------------------------------------------------------------
>
>                 Key: WICKET-1017
>                 URL: https://issues.apache.org/jira/browse/WICKET-1017
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.0-beta3
>            Reporter: Sebastiaan van Erk
>            Priority: Minor
>             Fix For: 1.3.0-rc2
>
>
> The POSITIVE validator is a new number validator with minimum 0.
> However 0 is not positive. Therefore, the validator should be called NONNEGATIVE. That or it should not allow 0.
> The validation messages (at least in Dutch) state that the number must be LARGER than 0 if I enter a negative number.
> However, 0 is of course accepted.
> Thus, for consistency I think it would probably be best to fix this one way or the other.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-1017) POSITIVE and NEGATIVE in NumberValidator are badly named (or contain a bug)

Posted by "Sebastiaan van Erk (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12552703 ] 

Sebastiaan van Erk commented on WICKET-1017:
--------------------------------------------

It's a beautiful fix, it took me a while to understand it. :-)

Double.MIN_VALUE is *REALLY* counterintuitive (especially considering Integer.MIN_VALUE).

bsh % -1.0 < Double.MIN_VALUE;
<true>
bsh % -1 < Integer.MIN_VALUE;
<false>

I still think it's a good idea to deprecate POSITIVE and NEGATIVE as Igor suggested and at least cleary mention the API change, because there will probably be people depending on the old behavior.


> POSITIVE and NEGATIVE in NumberValidator are badly named (or contain a bug)
> ---------------------------------------------------------------------------
>
>                 Key: WICKET-1017
>                 URL: https://issues.apache.org/jira/browse/WICKET-1017
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.0-beta3
>            Reporter: Sebastiaan van Erk
>            Assignee: Johan Compagner
>            Priority: Minor
>             Fix For: 1.3.0-rc3
>
>
> The POSITIVE validator is a new number validator with minimum 0.
> However 0 is not positive. Therefore, the validator should be called NONNEGATIVE. That or it should not allow 0.
> The validation messages (at least in Dutch) state that the number must be LARGER than 0 if I enter a negative number.
> However, 0 is of course accepted.
> Thus, for consistency I think it would probably be best to fix this one way or the other.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.