<?xml version="1.0" encoding="UTF-8"?>
<validateThis xsi:noNamespaceSchemaLocation="http://
www.validatethis.org/validateThis.xsd" xmlns:xsi="http://www.w3.org/
2001/XMLSchema-instance">
<contexts>
<context name="Add" formName="frmEdit" />
<context name="Edit" formName="frmEdit" />
</contexts>
<objectProperties>
<property name="clientName" desc="Client Name">
<rule type="required" contexts="*" />
</property>
<property name="clientPassword" desc="Password">
<rule type="required" contexts="Add" />
<rule type="rangelength" contexts="*">
<param name="minlength" value="5" />
<param name="maxlength" value="100" />
</rule>
</property>
<property name="VerifyPassword">
<rule type="required" contexts="Add" />
<rule type="equalTo" contexts="*">
<param name="ComparePropertyName" value="clientPassword" />
</rule>
</property>
</objectProperties>
</validateThis>
However, if I try to move the rules into the component itself, if I
edit a client and do not enter anything into the password field, I get
an error that "The Password must be between 5 and 10 characters long."
Here is my component.
component displayname="Client" output="false" persistent="true"
table="tblClient" extends="BaseORMService" {
property name="clientID" type="numeric" fieldtype="id"
generator="native";
property name="clientName" displayName="Client Name" type="string"
vtRules='[
{"type":"required","contexts":"*"}
]';
property name="clientPassword" displayName="Password" type="string"
vtRules='[
{"type":"required","contexts":"Add"},
{"type":"rangelength","contexts":"*",
"params":[
{"name":"minlength","value":"5"},
{"name":"maxlength","value":"10"}
]
}
]';
property name="address" type="string";
property name="address2" type="string";
property name="city" type="string";
property name="state" type="string";
property name="postalCode" type="string";
property name="phone" type="string";
property name="contactName" type="string";
property name="contactEmail" type="string";
property name="deals" type="array" fieldtype="one-to-many" cfc="Deal"
singularname="deal" fkcolumn="clientID" inverse="true" cascade="all-
delete-orphan";
property name="dteCreated" type="string" ormtype="timestamp";
property name="dteModified" type="string" ormtype="timestamp";
property name="verifyPassword" type="string" persistent="false"
vtRules='[
{"type":"required","contexts":"Add"},
{"type":"equalTo","contexts":"*",
"params" : [
{"name":"ComparePropertyName","value":"clientPassword"}
]
}
]';
}
Am I just coding my component wrong or is this a bug?
Thanks,
Dean
In the meantime, can you do the following?
On the page that processes the form, where you'd normally call:
result = validateThis.validate(object);
can you instead do this:
contexts = validateThis.getAllContexts(object);
and then dump the contents of contexts and show us what it holds?
Thanks,
Bob
> --
> 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.
>
--
Bob Silverberg
www.silverwareconsulting.com
I did a dump of both rule methods and compared them and they were both
identical except for the max password value. The xml version was set
to 100 (the actual db field length) and the annotation version was set
at 10. I realized that I am encrypting the password which is making
the string longer than 10 characters, which would explain why
ValidateThis was throwing a failed validation. So it appears that it
is working properly and it was indeed my fault.
Thanks for pointing in the right direction.
Dean