CFLib.org – Common Function Library Project

isArrayOfStructs(object)

Last updated December 19, 2012

author

Jon Briccetti

Version: 1 | Requires: CF9 | Library: DataManipulationLib

Description:
Allows you to check if a variable contains an array of structs.

Return Values:
Returns a boolean

Example:

numbers = [
    {number=1, english="one", maori="tahi"},
    {number=2, english="two", maori="rua"},
    {number=3, english="three", maori="toru"},
    {number=4, english="four", maori="wha"}
];

writeOutput(isArrayOfStructs(numbers));

Parameters:

Name Description Required
object The object to validate Yes

Full UDF Source:

/**
 * Tells you if a variable is an array of structs
 * version 0.9 by Jon Briccetti
 * version 1.0 by Adam Cameron (tidied logic, converted to script, removed some extraneous logic that didn't fit the function's stated purpose)
 * 
 * @param object 	 The object to validate (Required)
 * @return Returns a boolean 
 * @author Jon Briccetti (jbriccetti@gmail.com) 
 * @version 1.0, December 19, 2012 
 */
function isArrayOfStructs(object){
	if (!isArray(object)){
		return false;
	}
	for (var element in object){
		if (!isStruct(element)){
			return false;
		}
	}
	return true;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson