Only Validate Specific Fields or Ignore Specific Fields

8 views
Skip to first unread message

Tim B

unread,
Oct 15, 2013, 4:04:46 PM10/15/13
to validate...@googlegroups.com
How is there a way to specify what fields I want to be validated or which ones I don't? I've read through the docs and api a bunch and can't figure it out.

ie:
application.ValidateThis.validate(objectType="User",theObject=form, only="Nickname,Password");

or

application.ValidateThis.validate(objectType="User",theObject=form, except="Email,Phone,Address,City,State");

Help appreciated :)

John Whish

unread,
Oct 16, 2013, 4:27:11 AM10/16/13
to ValidateThis-dev
Hi Tim,

You want to use contexts. Something like this:

		<property name="FirstName">
			<rule type="required" contexts="Profile" />
		</property>
		<property name="LastName">
			<rule type="required" contexts="Profile" />
			<rule type="required" contexts="Register">
				<param name="DependentPropertyName" value="FirstName" />
			</rule>
		</property>

Then you pass in the context you want to use when you validate it:

<cfset Result = application.ValidateThis.validate(myObject,'User','Register') />

Have a look at the sample applications. For example:


Hope that helps!

BTW: This is the development list for ValidateThis, the main mailing list is https://groups.google.com/forum/#!forum/validatethis so posting in that list will reach more people and probably get a quicker response.




--
You received this message because you are subscribed to the Google Groups "ValidateThis-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to validatethis-d...@googlegroups.com.
To post to this group, send email to validate...@googlegroups.com.
Visit this group at http://groups.google.com/group/validatethis-dev.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages