View Issue Details

IDProjectCategoryView StatusLast Update
0005566JEDI VCL04 Feature Requestpublic2011-09-21 14:10
ReporterjkelleyAssigned Toobones 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product VersionDaily / GIT 
Target VersionFixed in Version3.45 
Summary0005566: TJvRequiredFieldValidator should support trimming before validation
DescriptionIf 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.
TagsNo tags attached.

Activities

jfudickar

2011-05-09 21:46

developer   ~0018547

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;
 

jkelley

2011-05-23 18:49

reporter   ~0018558

Done. Thanks.

obones

2011-06-08 15:17

administrator   ~0018672

Thanks, this is now in SVN

Issue History

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