View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0005566 | JEDI VCL | 04 Feature Request | public | 2011-05-03 20:33 | 2011-09-21 14:10 |
| Reporter | jkelley | Assigned To | obones | ||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | resolved | Resolution | fixed | ||
| Product Version | Daily / GIT | ||||
| Target Version | Fixed in Version | 3.45 | |||
| Summary | 0005566: TJvRequiredFieldValidator should support trimming before validation | ||||
| Description | If I'm using a TJvRequiredFieldValidator to require that a TEdit control be non-empty, I probably also want to make sure that it's not just blank spaces. JvValidators doesn't currently support this use case. Perhaps add a boolean field "AllowBlank", defaulting to true (for backwards compatibility), and if it's false, then check Not VarToStr(R).TrimRight().IsEmpty() instead of VarCompareValue(R, '') <> vrEqual If this approach sounds good, I can submit a patch. | ||||
| Tags | No tags attached. | ||||
|
|
For me this sounds good :-) So we are waiting for your patch :-) |
|
2011-05-23 18:48
|
jvvalidators-allowblank.patch (882 bytes)
Index: JvValidators.pas
===================================================================
--- JvValidators.pas (revision 5369)
+++ JvValidators.pas (working copy)
@@ -135,8 +135,12 @@
end;
TJvRequiredFieldValidator = class(TJvBaseValidator)
+ private
+ FAllowBlank: Boolean;
protected
procedure Validate; override;
+ published
+ property AllowBlank: Boolean read FAllowBlank write FAllowBlank default true;
end;
TJvValidateCompareOperator = (vcoLessThan, vcoLessOrEqual, vcoEqual, vcoGreaterOrEqual, vcoGreaterThan, vcoNotEqual);
@@ -544,7 +548,10 @@
varByte:
; // nothing to do because all values are valid
else
- Valid := VarCompareValue(R, '') <> vrEqual;
+ if FAllowBlank then
+ Valid := VarCompareValue(R, '') <> vrEqual
+ else
+ Valid := Trim(VarToStr(R)) <> '';
end;
end;
|
|
|
Done. Thanks. |
|
|
Thanks, this is now in SVN |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2011-05-03 20:33 | jkelley | New Issue | |
| 2011-05-09 21:46 | jfudickar | Note Added: 0018547 | |
| 2011-05-09 21:46 | jfudickar | Status | new => feedback |
| 2011-05-23 18:48 | jkelley | File Added: jvvalidators-allowblank.patch | |
| 2011-05-23 18:49 | jkelley | Note Added: 0018558 | |
| 2011-06-07 17:42 | obones | Status | feedback => acknowledged |
| 2011-06-08 15:17 | obones | Note Added: 0018672 | |
| 2011-06-08 15:17 | obones | Status | acknowledged => resolved |
| 2011-06-08 15:17 | obones | Fixed in Version | => Daily / SVN |
| 2011-06-08 15:17 | obones | Resolution | open => fixed |
| 2011-06-08 15:17 | obones | Assigned To | => obones |
| 2011-09-21 14:10 | obones | Fixed in Version | Daily / SVN => 3.45 |