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;
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson