In fact, ColdFusion supports some support for validation type arrays (which should not be confused with typed arrays), but it only works with custom components not for primitive types . However, I did not find any other documentation for this feature other than this blog post .
Suppose we have a SomeObject component.
We could write:
<cffunction name="testArrayTypeValidation"> <cfargument name="someObjects" type="SomeObject[]" required="yes"> <cfdump var="#someObjects#"> </cffunction>
And then call our function as follows:
<cfset testArrayTypeValidation([new SomeObject()])>
However, be careful that it will only check the type of the first element in the array, which means the following will also work:
<cfset testArrayTypeValidation([new SomeObject(), 'some string'])>
In addition, it does not work for primitive types, so you cannot use type="string[]" , for example, which is sad.
For primitive types, you will have to implement your own specific wrapper class that will contain only primitives of a certain type and use this class as an argument type.
plalx source share