OOPhoto - No More Validation In The Controller

<!--- Check photos. --->
<cfif NOT IsArray( ARGUMENTS.Gallery.GetPhotos() )>
 
	<cfset ARGUMENTS.Errors.Photos = "InvalidValue" />
 
<cfelseif NOT ArrayLen( ARGUMENTS.Gallery.GetPhotos() )>
 
	<cfset ARGUMENTS.Errors.Photos = "Required" />
 
<cfelse>
 
	<!---
		Since we have photos, we need to validate each one
		of the photos as well. Let's start off with by creating
		a key for it.
	--->
	<cfset ARGUMENTS.Errors.Photos = [] />
 
	<!--- Now, loop over each photo to validate. --->
	<cfloop
		index="LOCAL.Photo"
		array="#ARGUMENTS.Gallery.GetPhotos()#">
 
		<!--- Validate photo. --->
		<cfset LOCAL.Errors = LOCAL.Photo.Validate( StructNew() ) />
 
		<!--- Check to see if we found any errors. --->
		<cfif StructCount( LOCAL.Errors )>
 
			<!--- Add to the array of errors. --->
			<cfset ArrayAppend(
				ARGUMENTS.Errors.Photos,
				LOCAL.Errors
				) />
 
		</cfif>
 
	</cfloop>
 
	<!---
		Now that we have looped through all the photos, check
		to see if we found any errors. If we did NOT, then,
		let's remove that key.
	--->
	<cfif NOT ArrayLen( ARGUMENTS.Errors.Photos )>
 
		<!--- Delete key. --->
		<cfset StructDelete( ARGUMENTS.Errors, "Photos" ) />
 
	</cfif>
 
</cfif>

For Cut-and-Paste