You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Francisco Diaz Trepat - gmail <fr...@gmail.com> on 2007/10/11 21:06:47 UTC
Validating a NonZero Values and Validators Project in General
Hi, I am using Apache Wicket 1.3.0-beta2 and want to have a nonzero positive
validator, a nonzero negative, and a nonzero positive or negative.
I saw that wicket comes with the NumberValidator.minimum maximun etc.
Will there be more validators added to the framework?
Is there a stuff project or smaller project in which to contribute?
Could I have these validators without implementing my own?
f(t)
Re: Validating a NonZero Values and Validators Project in General
Posted by Kent Tong <ke...@cpttm.org.mo>.
Francisco Diaz Trepat - gmail wrote:
>
> Although I think maybe there are some validators we would all use like
> those
> already included in wicket.
>
nonzero positive: NumberValidator.minimum(1)
nonzero negative: NumberValidator.maximum(-1)
nonzero positive or negative: do as Gwyn suggested. If you insist on using a
pre-built
validator, try PatternValidator("[+|-]?(\\d)*[1-9](\\d)*") but then the
model has to
be a String, not a number.
-----
--
Kent Tong
Wicket tutorials freely available at http://www.agileskills2.org/EWDW
--
View this message in context: http://www.nabble.com/Validating-a-NonZero-Values-and-Validators-Project-in-General-tf4609372.html#a13172551
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Validating a NonZero Values and Validators Project in General
Posted by Francisco Diaz Trepat - gmail <fr...@gmail.com>.
Thanks Gwyn.
I understand.
Although I think maybe there are some validators we would all use like those
already included in wicket.
f(t)
On 10/11/07, Gwyn Evans <gw...@gmail.com> wrote:
>
> On Thursday, October 11, 2007, 8:06:47 PM, Francisco <
> francisco.diaztrepat@gmail.com> wrote:
>
> > Hi, I am using Apache Wicket 1.3.0-beta2 and want to have a nonzero
> positive
> > validator, a nonzero negative, and a nonzero positive or negative.
>
> > I saw that wicket comes with the NumberValidator.minimum maximun etc.
> > Will there be more validators added to the framework?
> > Is there a stuff project or smaller project in which to contribute?
> > Could I have these validators without implementing my own?
>
> You could supply a patch to NumberValidator, but they're not really
> complex, e.g.
>
> /**
> * Validator to check the number is greater than zero
> */
> public class PositiveLongValidator extends AbstractValidator {
> protected void onValidate(IValidatable validatable) {
> final long value = ((Number) validatable.getValue
> ()).longValue();
> if (!(value > 0)) {
> error(validatable);
> }
> }
> }
>
> /Gwyn
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Validating a NonZero Values and Validators Project in General
Posted by Gwyn Evans <gw...@gmail.com>.
On Thursday, October 11, 2007, 8:06:47 PM, Francisco <fr...@gmail.com> wrote:
> Hi, I am using Apache Wicket 1.3.0-beta2 and want to have a nonzero positive
> validator, a nonzero negative, and a nonzero positive or negative.
> I saw that wicket comes with the NumberValidator.minimum maximun etc.
> Will there be more validators added to the framework?
> Is there a stuff project or smaller project in which to contribute?
> Could I have these validators without implementing my own?
You could supply a patch to NumberValidator, but they're not really
complex, e.g.
/**
* Validator to check the number is greater than zero
*/
public class PositiveLongValidator extends AbstractValidator {
protected void onValidate(IValidatable validatable) {
final long value = ((Number) validatable.getValue()).longValue();
if (!(value > 0)) {
error(validatable);
}
}
}
/Gwyn
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org