AW: Validator problem with integers
How about using a regexp? field property=phone depends=required, mask arg0 key=Daytime Phone box 3 resource=false/ var var-namemask/var-name var-value^\d{4}$/var-value /var /field HTH Robert -Ursprüngliche Nachricht- Von: David Graham [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 18. Juni 2003 23:13 An: [EMAIL PROTECTED] Betreff: Re: Validator problem with integers An integer validation is not the same as a are all characters numeric validation. I don't think the validator currently has a numeric check but patches are welcome. David Hi folks, Using struts-RC2, when using Validator with a dependency on integer validation, I have a problem with the validator assuming that any integer starting with zero 0 is necessarily octal. In one example, I have a form where people enter phone numbers. Which is split up into 3 text boxes. Area code, 3 digits, last 4 digits. A fairly common way to break it up. Here is the validation.xml entry for one such field: field property=dayPhone3 depends=required, integer, minlength, maxlength arg0 key=Daytime Phone box 3 resource=false/ arg1 name=minlength key=${var:minlength} resource=false/ arg2 name=maxlength key=${var:maxlength} resource=false/ var var-namemaxlength/var-name var-value4/var-value /var var var-nameminlength/var-name var-value4/var-value /var /field Numbers like 0897 will cause the ... must be an integer message. Obviously it is not a valid octal number, and I know that the format of these numbers would appear as an attempt at an octal number. How do you prevent octal interpretation but still ensure that the field is numeric? I'm being a tad lazy here, because I know I could always write my own pluggable validator, but I'd like to use what already exists if possible. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Validator problem with integers
Hi Brad, use mask instead of integer. That should do the job. Error message states, that the entry is invalid. BTW, arg1 has to be used both for minlength and maxlength since {1} is the argument in the error message. I found that mask can solve nearly all validation problems if they are constrained to one field. If you have interdependent fields you still have to go back and implement ActionForm::validate. field property=dayPhone3 depends=required,mask,minlength,maxlength arg0 key=Daytime Phone box 3 resource=false/ arg1 name=minlength key=${var:minlength} resource=false / arg1 name=maxlength key=${var:maxlength} resource=false / var var-namemask/var-name var-value^[0-9]*$/var-value /var var var-nameminlength/var-name var-value4/var-value /var var var-namemaxlength/var-name var-value4/var-value /var /field Markus Brad Plies wrote: Hi folks, Using struts-RC2, when using Validator with a dependency on integer validation, I have a problem with the validator assuming that any integer starting with zero 0 is necessarily octal. In one example, I have a form where people enter phone numbers. Which is split up into 3 text boxes. Area code, 3 digits, last 4 digits. A fairly common way to break it up. Here is the validation.xml entry for one such field: field property=dayPhone3 depends=required, integer, minlength, maxlength arg0 key=Daytime Phone box 3 resource=false/ arg1 name=minlength key=${var:minlength} resource=false/ arg2 name=maxlength key=${var:maxlength} resource=false/ var var-namemaxlength/var-name var-value4/var-value /var var var-nameminlength/var-name var-value4/var-value /var /field Numbers like 0897 will cause the ... must be an integer message. Obviously it is not a valid octal number, and I know that the format of these numbers would appear as an attempt at an octal number. How do you prevent octal interpretation but still ensure that the field is numeric? I'm being a tad lazy here, because I know I could always write my own pluggable validator, but I'd like to use what already exists if possible. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Validator problem with integers
You are correct, my choice of words inadvertently changed the problem statement to something that I didn't mean. Very sharp eyes there. An integer validation is not the same as a are all characters numeric validation. I don't think the validator currently has a numeric check but patches are welcome. David
Re: Validator problem with integers
Thank you Robert Markus for your mask suggestions will work beautifully. I would have seen it before I suppose if I were more comfortable with regexp notation. Thank you again, Brad - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Validator problem with integers
Hi folks, Using struts-RC2, when using Validator with a dependency on integer validation, I have a problem with the validator assuming that any integer starting with zero 0 is necessarily octal. In one example, I have a form where people enter phone numbers. Which is split up into 3 text boxes. Area code, 3 digits, last 4 digits. A fairly common way to break it up. Here is the validation.xml entry for one such field: field property=dayPhone3 depends=required, integer, minlength, maxlength arg0 key=Daytime Phone box 3 resource=false/ arg1 name=minlength key=${var:minlength} resource=false/ arg2 name=maxlength key=${var:maxlength} resource=false/ var var-namemaxlength/var-name var-value4/var-value /var var var-nameminlength/var-name var-value4/var-value /var /field Numbers like 0897 will cause the ... must be an integer message. Obviously it is not a valid octal number, and I know that the format of these numbers would appear as an attempt at an octal number. How do you prevent octal interpretation but still ensure that the field is numeric? I'm being a tad lazy here, because I know I could always write my own pluggable validator, but I'd like to use what already exists if possible. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Validator problem with integers
An integer validation is not the same as a are all characters numeric validation. I don't think the validator currently has a numeric check but patches are welcome. David Hi folks, Using struts-RC2, when using Validator with a dependency on integer validation, I have a problem with the validator assuming that any integer starting with zero 0 is necessarily octal. In one example, I have a form where people enter phone numbers. Which is split up into 3 text boxes. Area code, 3 digits, last 4 digits. A fairly common way to break it up. Here is the validation.xml entry for one such field: field property=dayPhone3 depends=required, integer, minlength, maxlength arg0 key=Daytime Phone box 3 resource=false/ arg1 name=minlength key=${var:minlength} resource=false/ arg2 name=maxlength key=${var:maxlength} resource=false/ var var-namemaxlength/var-name var-value4/var-value /var var var-nameminlength/var-name var-value4/var-value /var /field Numbers like 0897 will cause the ... must be an integer message. Obviously it is not a valid octal number, and I know that the format of these numbers would appear as an attempt at an octal number. How do you prevent octal interpretation but still ensure that the field is numeric? I'm being a tad lazy here, because I know I could always write my own pluggable validator, but I'd like to use what already exists if possible. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Validator problem with integers
There is a js function called isAllDigits(arg) in validator-rules.xml. It's used by validateInteger(). You can use that. Yan -Original Message- From: David Graham [mailto:[EMAIL PROTECTED] Sent: June 18, 2003 3:13 PM To: [EMAIL PROTECTED] Subject: Re: Validator problem with integers An integer validation is not the same as a are all characters numeric validation. I don't think the validator currently has a numeric check but patches are welcome. David Hi folks, Using struts-RC2, when using Validator with a dependency on integer validation, I have a problem with the validator assuming that any integer starting with zero 0 is necessarily octal. In one example, I have a form where people enter phone numbers. Which is split up into 3 text boxes. Area code, 3 digits, last 4 digits. A fairly common way to break it up. Here is the validation.xml entry for one such field: field property=dayPhone3 depends=required, integer, minlength, maxlength arg0 key=Daytime Phone box 3 resource=false/ arg1 name=minlength key=${var:minlength} resource=false/ arg2 name=maxlength key=${var:maxlength} resource=false/ var var-namemaxlength/var-name var-value4/var-value /var var var-nameminlength/var-name var-value4/var-value /var /field Numbers like 0897 will cause the ... must be an integer message. Obviously it is not a valid octal number, and I know that the format of these numbers would appear as an attempt at an octal number. How do you prevent octal interpretation but still ensure that the field is numeric? I'm being a tad lazy here, because I know I could always write my own pluggable validator, but I'd like to use what already exists if possible. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Validator problem with integers
There is a js function called isAllDigits(arg) in validator-rules.xml. It's used by validateInteger(). You can use that. No you can't because that function validates based on the type of number (int, octal, etc). David Yan -Original Message- From: David Graham [mailto:[EMAIL PROTECTED] Sent: June 18, 2003 3:13 PM To: [EMAIL PROTECTED] Subject: Re: Validator problem with integers An integer validation is not the same as a are all characters numeric validation. I don't think the validator currently has a numeric check but patches are welcome. David Hi folks, Using struts-RC2, when using Validator with a dependency on integer validation, I have a problem with the validator assuming that any integer starting with zero 0 is necessarily octal. In one example, I have a form where people enter phone numbers. Which is split up into 3 text boxes. Area code, 3 digits, last 4 digits. A fairly common way to break it up. Here is the validation.xml entry for one such field: field property=dayPhone3 depends=required, integer, minlength, maxlength arg0 key=Daytime Phone box 3 resource=false/ arg1 name=minlength key=${var:minlength} resource=false/ arg2 name=maxlength key=${var:maxlength} resource=false/ var var-namemaxlength/var-name var-value4/var-value /var var var-nameminlength/var-name var-value4/var-value /var /field Numbers like 0897 will cause the ... must be an integer message. Obviously it is not a valid octal number, and I know that the format of these numbers would appear as an attempt at an octal number. How do you prevent octal interpretation but still ensure that the field is numeric? I'm being a tad lazy here, because I know I could always write my own pluggable validator, but I'd like to use what already exists if possible. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Validator problem with integers
Oh yeah. Sorry Well, at least I pinpointed where the check failed:). There is a js function called isAllDigits(arg) in validator-rules.xml. It's used by validateInteger(). You can use that. No you can't because that function validates based on the type of number (int, octal, etc). David Yan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Validator problem with integers
Huh? How come nobody noticed this before? Shouldn't the for statement be like this: - for (var n = startFrom; n argvalue.length; n++) { if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false; } Assigning var n =0; doesn't make sense to me -- function isAllDigits(argvalue) { argvalue = argvalue.toString(); var validChars = 0123456789; var startFrom = 0; if (argvalue.substring(0, 2) == 0x) { validChars = 0123456789abcdefABCDEF; startFrom = 2; } else if (argvalue.charAt(0) == 0) { validChars = 01234567; startFrom = 1; } for (var n = 0; n argvalue.length; n++) { if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false; } return true; } - -Original Message- From: Yansheng Lin [mailto:[EMAIL PROTECTED] Sent: June 18, 2003 4:23 PM To: 'Struts Users Mailing List' Subject: RE: Validator problem with integers Oh yeah. Sorry Well, at least I pinpointed where the check failed:). There is a js function called isAllDigits(arg) in validator-rules.xml. It's used by validateInteger(). You can use that. No you can't because that function validates based on the type of number (int, octal, etc). David Yan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Validator problem with integers
Oh they fixed the bug. The version I downloaded must be old. -Original Message- From: Yansheng Lin [mailto:[EMAIL PROTECTED] Sent: June 18, 2003 4:45 PM To: 'Struts Users Mailing List' Subject: RE: Validator problem with integers Huh? How come nobody noticed this before? Shouldn't the for statement be like this: - for (var n = startFrom; n argvalue.length; n++) { if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false; } Assigning var n =0; doesn't make sense to me -- function isAllDigits(argvalue) { argvalue = argvalue.toString(); var validChars = 0123456789; var startFrom = 0; if (argvalue.substring(0, 2) == 0x) { validChars = 0123456789abcdefABCDEF; startFrom = 2; } else if (argvalue.charAt(0) == 0) { validChars = 01234567; startFrom = 1; } for (var n = 0; n argvalue.length; n++) { if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false; } return true; } - -Original Message- From: Yansheng Lin [mailto:[EMAIL PROTECTED] Sent: June 18, 2003 4:23 PM To: 'Struts Users Mailing List' Subject: RE: Validator problem with integers Oh yeah. Sorry Well, at least I pinpointed where the check failed:). There is a js function called isAllDigits(arg) in validator-rules.xml. It's used by validateInteger(). You can use that. No you can't because that function validates based on the type of number (int, octal, etc). David Yan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]