<cffunction
name="Validate"
access="public"
returntype="struct"
output="false"
hint="I validate the properties of the given comment and place error messages in given struct.">
<cfargument
name="Comment"
type="any"
required="true"
hint="I am the comment that is being validated."
/>
<cfargument
name="Errors"
type="struct"
required="false"
default="#StructNew()#"
hint="I am the struct into which erorrs will be placed."
/>
<cfif NOT IsSimpleValue( ARGUMENTS.Comment.GetComment() )>
<cfset ARGUMENTS.Errors.Comment = "InvalidValue" />
<cfelseif NOT Len( ARGUMENTS.Comment.GetComment() )>
<cfset ARGUMENTS.Errors.Comment = "Required" />
<cfelseif (Len( ARGUMENTS.Comment.GetComment() ) GT 500)>
<cfset ARGUMENTS.Errors.Comment = "InvalidLength" />
</cfif>
<cfif NOT IsDate( ARGUMENTS.Comment.GetDateCreated() )>
<cfset ARGUMENTS.Errors.DateCreated = "InvalidValue" />
</cfif>
<cfif IsSimpleValue( ARGUMENTS.Comment.GetPhoto() )>
<cfset ARGUMENTS.Errors.Photo = "Required" />
</cfif>
<cfreturn ARGUMENTS.Errors />
</cffunction>