Skip to content

Commit

Permalink
add validValues for string Properties #109
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Malley <[email protected]>
  • Loading branch information
pixelzoom committed May 22, 2018
1 parent b7fcc83 commit 8fd66f1
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions js/common/model/PlinkoProbabilityCommonModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,24 @@ define( function( require ) {
// @public {number} this can be a number between 0 and 1
this.probabilityProperty = new Property( PlinkoProbabilityConstants.BINARY_PROBABILITY_RANGE.defaultValue );

// @public {string} controls how many balls are dispensed when the 'play' button is pressed, see BALL_MODE_VALUES
this.ballModeProperty = new Property( 'oneBall', { phetioType: PropertyIO( StringIO ) } );
// @public {string} controls how many balls are dispensed when the 'play' button is pressed
this.ballModeProperty = new Property( 'oneBall', {
validValues: BALL_MODE_VALUES,
phetioType: PropertyIO( StringIO )
} );

// {string} controls what comes out of the hopper above the Galton board, see HOPPER_MODE_VALUES
this.hopperModeProperty = new Property( 'ball', { phetioType: PropertyIO( StringIO ) } );
// {string} controls what comes out of the hopper above the Galton board
this.hopperModeProperty = new Property( 'ball', {
validValues: HOPPER_MODE_VALUES,
phetioType: PropertyIO( StringIO )
} );

// {boolean} is the maximum number of balls reached?
this.isBallCapReachedProperty = new Property( false );

// {number} number of rows in the Galton board, must be an integer
this.numberOfRowsProperty = new Property( PlinkoProbabilityConstants.ROWS_RANGE.defaultValue );

// validate string values
this.ballModeProperty.link( function( ballMode ) {
assert && assert( _.includes( BALL_MODE_VALUES, ballMode ), 'invalid ballMode: ' + ballMode );
} );
this.hopperModeProperty.link( function( hopperMode ) {
assert && assert( _.includes( HOPPER_MODE_VALUES, hopperMode ), 'invalid hopperMode: ' + hopperMode );
} );

this.ballCreationTimeElapsed = 0; // @public {number} - time elapsed since last ball creation
this.balls = new ObservableArray(); // @public
this.galtonBoard = new GaltonBoard( this.numberOfRowsProperty ); // @public
Expand Down

1 comment on commit 8fd66f1

@pixelzoom
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.