lib/model/compiler.js
function validateAttributes( modelName, attributes = {}, errors = [] ) {
	if ( !attributes || typeof attributes !== "object" || Array.isArray( attributes ) ) {
		throw new TypeError( "definition of attributes must be object" );
	}

	const names = Object.keys( attributes );
	const handlers = {};

	for ( let i = 0, length = names.length; i < length; i++ ) {
		const name = names[i];
		const attribute = attributes[name];

		if ( !attribute.type ) {
			attribute.type = "string";
		}

		const type = Types.selectByName( attribute.type );
		if ( !type ) {
			throw new TypeError( `invalid attribute type "${attribute.type}" in attribute "${name}" of model "${modelName}"` );
		}

		if ( type.checkDefinition( attribute, errors ) ) {
			handlers[name] = type;
		}
	}

	return handlers;
}
function validateAttributes( modelName, attributes = {}, errors = [] ) {
	if ( !attributes || typeof attributes !== "object" || Array.isArray( attributes ) ) {
		throw new TypeError( "definition of attributes must be object" );
	}

	const names = Object.keys( attributes );
	const handlers = {};

	for ( let i = 0, length = names.length; i < length; i++ ) {
		const name = names[i];
		const attribute = attributes[name];

		if ( !attribute.type ) {
			attribute.type = "string";
		}

		const type = Types.selectByName( attribute.type );
		if ( !type ) {
			throw new TypeError( `invalid attribute type "${attribute.type}" in attribute "${name}" of model "${modelName}"` );
		}

		if ( type.checkDefinition( attribute, errors ) ) {
			handlers[name] = type;
		}
	}

	return handlers;
}
function validateAttributes ( modelName , attributes = { } , errors = [ ] ) { if ( ! attributes || typeof attributes !== "object" || Array . isArray ( attributes ) ) { throw new TypeError ( "definition of attributes must be object" ) ; } const names = Object . keys ( attributes ) ; const handlers = { } ; for ( let i = 0 , length = names . length ; i < length ; i ++ ) { const name = names [ i ] ; const attribute = attributes [ name ] ; if ( ! attribute . type ) { attribute . type = "string" ; } const type = Types . selectByName ( attribute . type ) ; if ( ! type ) { throw new TypeError ( ` ${ attribute . type } ${ name } ${ modelName } ` ) ; } if ( type . checkDefinition ( attribute , errors ) ) { handlers [ name ] = type ; } } return handlers ; }
Basically validates provided definitions of attributes.

@note Qualification of attributes' definitions are applied to provided object
and thus alter the provided set of definitions, too.

@param {string} modelName name of model definition of attributes is used for
@param {object<string,object>} attributes definition of attributes, might be adjusted on return
@param {Error[]} errors collector of processing errors
@returns {object<string,ModelType>} provided set of attribute definitions incl. optional qualifications
@throws TypeError on encountering severe issues with provided definition
Basically validates provided definitions of attributes .