Skip to content
Luis Majano edited this page Nov 30, 2015 · 3 revisions

After validation you can use the same results object and use it to display the validation errors in your client side:

Handlers:

// store the validation results in the request collection
prc.validationResults = validateModel( obj );

Views:

<-- Display all errors as a message box --->
#getInstance( "MessageBox@cbMessagebox" )
	.renderMessage( type="error", messageArray=prc.validationResults.getAllErrors() )#

If you want more control you can use the hasErrors() and iterate over the errors to display:

<cfif prc.validationResults.hasErrors()>
	<ul>
	<cfloop array="#prc.validationResults.getErrors()#" index="thisError">
		<li>#thisError.getMessage()#</li>
	</cfloop>
	</ul>
</cfif>

You can even use the results object in your views to get specific field errors, messagesbox, etc.

Common Methods

Clone this wiki locally