diff --git a/js/LinkedElementIO.js b/js/LinkedElementIO.js index 3a933210..7aa75ed6 100644 --- a/js/LinkedElementIO.js +++ b/js/LinkedElementIO.js @@ -24,6 +24,7 @@ define( function( require ) { phetioInherit( ObjectIO, 'LinkedElementIO', LinkedElementIO, {}, { documentation: 'A LinkedElement', + validator: { isValidValue: () => true }, /** * @param {LinkedElement} linkedElement diff --git a/js/phetioInherit.js b/js/phetioInherit.js index ca429d55..5c82f367 100644 --- a/js/phetioInherit.js +++ b/js/phetioInherit.js @@ -28,7 +28,9 @@ define( function( require ) { inherit( supertype, subtype, methods, staticProperties ); - staticProperties = staticProperties || {}; + assert && assert( staticProperties, 'static properties must be defined' ); + assert && assert( staticProperties.validator, 'validator must be provided' ); + ValidatorDef.validateValidator( staticProperties.validator ); if ( staticProperties.parameterTypes ) { assert && assert( Array.isArray( staticProperties.parameterTypes ), 'parameterTypes expected to be array' ); @@ -38,11 +40,6 @@ define( function( require ) { .join( ', ' ) + '>'; } - // TODO: isn't this field required? see https://github.com/phetsims/axon/issues/204 - if( staticProperties.validator){ - ValidatorDef.validateValidator( staticProperties.validator); - } - // The method order is used to determine the ordering of the documentation for a type's methods, see Studio for usage. subtype.methodOrder = staticProperties.methodOrder || []; subtype.methodOrder.forEach( function( methodName ) { diff --git a/js/types/ObjectIO.js b/js/types/ObjectIO.js index 93950d9e..9e3aa21e 100644 --- a/js/types/ObjectIO.js +++ b/js/types/ObjectIO.js @@ -13,6 +13,7 @@ define( function( require ) { // modules var phetioInherit = require( 'TANDEM/phetioInherit' ); var tandemNamespace = require( 'TANDEM/tandemNamespace' ); + var validate = require( 'AXON/validate' ); /** * Main constructor for ObjectIO base IO type. @@ -30,6 +31,9 @@ define( function( require ) { // @public (read-only) this.phetioID = phetioID; + + // Use the validator defined on the constructor to make sure the instance is valid + assert && validate( instance, this.constructor.validator ); } // ObjectIO inherits from window.Object because it starts with its prototype in phetioInherit.inheritBase