index.js
function validateClassConfig(obj) {
  /** If configuration is not plain object, throw error */
  if ( typeof obj != `object` || obj.constructor.name != `Object` )
    throw new Error(`ezobjects.validateClassConfig(): Invalid table configuration argument, must be plain object.`);
    
  /** If configuration has missing or invalid 'className' configuration, throw error */
  if ( typeof obj.className !== 'string' || !obj.className.match(/^[A-Za-z_0-9$]+$/) )
    throw new Error(`ezobjects.validateClassConfig(): Configuration has missing or invalid 'className', must be string containing characters 'A-Za-z_0-9$'.`);

  /** Add properties array if one wasn't set */
  if ( !obj.properties )
    obj.properties = [];

  /** Make sure properties is array */
  if ( obj.properties && ( typeof obj.properties != 'object' || obj.properties.constructor.name != 'Array' ) )
    throw new Error(`ezobjects.validateClassConfig(): Invalid properties configuration, properties not array.`);
  
  /** Loop through any properties and validate them */
  obj.properties.forEach((property) => {
    property.className = obj.className;
    
    validatePropertyConfig(property);
  });
}
function validateClassConfig(obj) {
  /** If configuration is not plain object, throw error */
  if ( typeof obj != `object` || obj.constructor.name != `Object` )
    throw new Error(`ezobjects.validateClassConfig(): Invalid table configuration argument, must be plain object.`);
    
  /** If configuration has missing or invalid 'className' configuration, throw error */
  if ( typeof obj.className !== 'string' || !obj.className.match(/^[A-Za-z_0-9$]+$/) )
    throw new Error(`ezobjects.validateClassConfig(): Configuration has missing or invalid 'className', must be string containing characters 'A-Za-z_0-9$'.`);

  /** Add properties array if one wasn't set */
  if ( !obj.properties )
    obj.properties = [];

  /** Make sure properties is array */
  if ( obj.properties && ( typeof obj.properties != 'object' || obj.properties.constructor.name != 'Array' ) )
    throw new Error(`ezobjects.validateClassConfig(): Invalid properties configuration, properties not array.`);
  
  /** Loop through any properties and validate them */
  obj.properties.forEach((property) => {
    property.className = obj.className;
    
    validatePropertyConfig(property);
  });
}
function validateClassConfig ( obj ) { /** If configuration is not plain object, throw error */ if ( typeof obj != ` ` || obj . constructor . name != ` ` ) throw new Error ( ` ` ) ; /** If configuration has missing or invalid 'className' configuration, throw error */ if ( typeof obj . className !== 'string' || ! obj . className . match ( / ^[A-Za-z_0-9$]+$ / ) ) throw new Error ( ` ` ) ; /** Add properties array if one wasn't set */ if ( ! obj . properties ) obj . properties = [ ] ; /** Make sure properties is array */ if ( obj . properties && ( typeof obj . properties != 'object' || obj . properties . constructor . name != 'Array' ) ) throw new Error ( ` ` ) ; /** Loop through any properties and validate them */ obj . properties . forEach ( ( property ) => { property . className = obj . className ; validatePropertyConfig ( property ) ; } ) ; }
Validate configuration for a class
Validate configuration for a class