Skip to content

Commit

Permalink
check state is valid based on parameterType that serialized it, Utter…
Browse files Browse the repository at this point in the history
…ance.toStateObject to use IOType to serialize, phetsims/center-and-variability#113 phetsims/tambo#160
  • Loading branch information
zepumph committed Mar 29, 2022
1 parent 264f9eb commit fe151c2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion js/types/OrIO.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,14 @@ const OrIO = parameterTypes => {
return parameterTypes[ stateObject.index ].fromStateObject( stateObject.state );
},
stateSchema: StateSchema.asValue( `${typeNames.join( '|' )}`, {
isValidValue: isValidValue
isValidValue: stateObject => {

// Check based on the parameter that serialized the state
if ( typeof stateObject.index === 'number' ) {
return parameterTypes[ stateObject.index ].isStateObjectValid( stateObject.state );
}
return false;
}
} )
} ) );
}
Expand Down

0 comments on commit fe151c2

Please sign in to comment.