<property name="password" desc="Password">
<rule type="required" contexts="*" />
<rule type="rangelength" contexts="*">
<param minlength="6" />
<param maxlength="12" />
</rule>
</property>
versus this rule (case 2)...
<property name="password" desc="Password">
<rule type="rangelength" contexts="*">
<param minlength="6" />
<param maxlength="12" />
</rule>
</property>
I remember you saying the rules were mutually exclusive, which would
imply that the additional 'required' rule in case 1 would not be
necessary, but perhaps I misunderstood.
In other words, does that mean that in case 2 the Password field is
not required? But, if someone does populate the Password field, that
it has to be between 6 and 12 characters?
Thanks,
Thomas
<cfset var Parameters = arguments.valObject.getParameters() />
<cfset var theLength = Len(arguments.valObject.getObjectValue()) />
<cfif theLength LT Parameters.MinLength OR theLength GT Parameters.MaxLength>
<cfset fail(arguments.valObject,"The #arguments.valObject.getPropertyDesc()# must be between #Parameters.MinLength# and #Parameters.MaxLength# characters long.") />
</cfif>
--
You received this message because you are subscribed to the Google Groups "ValidateThis" group.
To post to this group, send email to valida...@googlegroups.com.
To unsubscribe from this group, send email to validatethis...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/validatethis?hl=en.
I vote for building it into the CF9/Hibernate version of
ValidateThis :)
Thomas
On Mar 4, 8:21 am, Bob Silverberg <bob.silverb...@gmail.com> wrote:
> Rules are not mutually exclusive at all. In fact the opposite it true. Each
> and every rule you add to a property will be enforced for that property. Of
> course you can use contexts to have different rules apply in different use
> cases, and you can create conditions as well, which will cause rules to only
> be applied when conditions are met.
>
> Getting to your specific examples, whether a particular rule type also
> implies a "required" rule is based entirely on how the rule is coded. For
> your example of rangelength, the code for the ServerRuleValidator looks like
> this:
>
> <cfset var Parameters = arguments.valObject.getParameters() />
>
> <cfset var theLength = Len(arguments.valObject.getObjectValue()) />
>
> <cfif theLength LT Parameters.MinLength OR theLength GT Parameters.MaxLength
>
>
>
> <cfset fail(arguments.valObject,"The #arguments.valObject.getPropertyDesc()#
> must be between #Parameters.MinLength# and #Parameters.MaxLength# characters
> long.") />
>
> </cfif>
>
> What's happening there is that the length of the contents of the property is
> being determined, using Len(arguments.valObject.getObjectValue()) and then
> that length is being tested against the MinLength and MaxLength parameters.
> A length of 0 will naturally be less than the MinLength parameter, so the
> validation would fail if the property hadn't been populated. So that would
> mean that the rule would *imply *a required rule as well.
> > validatethis...@googlegroups.com<validatethis%2Bunsu...@googlegroups.com>
To unsubscribe from this group, send email to validatethis...@googlegroups.com.
T
> > <validatethis%2Bunsu...@googlegroups.com<validatethis%252Buns...@googlegroups.com>
Adding trim() will address that issue, as long as we're happy with
that definition. Do people think that a property/field that contains
only spaces should be considered empty?
Thanks,
Bob
On Sat, Apr 7, 2012 at 10:49 AM, Tony Garcia <tny...@gmail.com> wrote:
> hey Bob,
> Disregard that last email. I figured out that, for some reason because
> of a datepicker plugin I was using on the form field, there was always
> at least one empty space in the field when the form was submitted, so
> when the propertyHasValue() method was called in the Validation
> Object, the len(val) gt 0 check returned "true" even though no value
> was submitted. So I sent a pull request where I added a trim() to
> account for any blank spaces that were submitted.
>
> thanks,
> Tony
>
> On Mar 4 2010, 12:21 pm, Bob Silverberg <bob.silverb...@gmail.com>
> wrote:
>> Rules are not mutually exclusive at all. In fact the opposite it true. Each
>> and every rule you add to a property will be enforced for that property. Of
>> course you can use contexts to have different rules apply in different use
>> cases, and you can create conditions as well, which will cause rules to only
>> be applied when conditions are met.
>>
>> Getting to your specific examples, whether a particular rule type also
>> implies a "required" rule is based entirely on how the rule is coded. For
>> your example of rangelength, the code for the ServerRuleValidator looks like
>> this:
>>
>> <cfset var Parameters = arguments.valObject.getParameters() />
>>
>> <cfset var theLength = Len(arguments.valObject.getObjectValue()) />
>>
>> <cfif theLength LT Parameters.MinLength OR theLength GT Parameters.MaxLength
>>
>>
>>
>> <cfset fail(arguments.valObject,"The #arguments.valObject.getPropertyDesc()#
>> must be between #Parameters.MinLength# and #Parameters.MaxLength# characters
>> long.") />
>>
>> </cfif>
>>
>> What's happening there is that the length of the contents of the property is
>> being determined, using Len(arguments.valObject.getObjectValue()) and then
>> that length is being tested against the MinLength and MaxLength parameters.
>> A length of 0 will naturally be less than the MinLength parameter, so the
>> validation would fail if the property hadn't been populated. So that would
>> mean that the rule would *imply *a required rule as well.
>> > validatethis...@googlegroups.com<validatethis%2Bunsubscribe@google groups.com>
>> > .
>> > For more options, visit this group at
>> >http://groups.google.com/group/validatethis?hl=en.
>>
>> --
>> Bob Silverbergwww.silverwareconsulting.com
>>
>> Hands-on ColdFusion ORM Training @ cf.Objective() 2010www.ColdFusionOrmTraining.com
--
Bob Silverberg
www.silverwareconsulting.com
To unsubscribe from this group, send email to validatethis...@googlegroups.com.
Thanks everyone for your input,
Bob
On Sun, Apr 8, 2012 at 9:51 PM, Tony Garcia <tny...@gmail.com> wrote:
> To unsubscribe from this group, send email to validatethis...@googlegroups.com.