OOPhoto - No More Validation In The Controller

<!--- Validate the gallery. --->
<cfset LOCAL.ValidationErrors = LOCAL.Gallery.Validate() />
 
 
<!--- Check to see if we have any errors. --->
<cfif StructCount( LOCAL.ValidationErrors )>
 
	<!---
		There were object validation errors. Now, we need
		to return the errors to the View in a way that will
		make sense.
	--->
	<cfif StructKeyExists( LOCAL.ValidationErrors, "Name" )>
 
		<cfset LOCAL.Errors.name = LOCAL.ValidationErrors.Name />
 
	</cfif>
 
	<cfif StructKeyExists( LOCAL.ValidationErrors, "Description" )>
 
		<cfset LOCAL.Errors.description =
			LOCAL.ValidationErrors.Description />
 
	</cfif>
 
	<cfif StructKeyExists( LOCAL.ValidationErrors, "Photos" )>
 
		<cfset LOCAL.Errors.photo_id_list =
			LOCAL.ValidationErrors.Photos />
 
	</cfif>
 
<cfelse>
 
	<!--- Save gallery. --->
	<cfset ARGUMENTS.Data.Cache.Factory
		.Get( "PhotoGalleryService" )
		.SaveWithTransaction( LOCAL.Gallery )
		/>
 
	<!--- Redirect to gallery detail. --->
	<cflocation
		url="#ARGUMENTS.Data.Controller#?do=gallery.view&id=#LOCAL.Gallery.GetID()#"
		addtoken="false"
		/>
 
</cfif>

For Cut-and-Paste