mastermind.validation.models package

class mastermind.validation.models.numeric.MaximumAttempts[source]

Bases: ConstrainedInteger

A ConstrainedInteger that validates the maximum number of attempts allowed in the game.

The maximum number of attempts must be greater than or equal to 1.

class mastermind.validation.models.numeric.NumberOfColors[source]

Bases: ConstrainedInteger

A ConstrainedInteger that validates the number of colors in the game.

The number of colors must be greater than or equal to 2.

class mastermind.validation.models.numeric.NumberOfDots[source]

Bases: ConstrainedInteger

A ConstrainedInteger that validates the number of dots in the game.

The number of dots must be greater than or equal to 2.

class mastermind.validation.models.numeric.NumberOfGuessesMade[source]

Bases: ConstrainedInteger

A ConstrainedInteger that validates the number of guesses made in the game.

The number of guesses must be greater than or equal to 0.

class mastermind.validation.models.valid_combination.ValidCombination(number_of_dots: int, number_of_colors: int)[source]

Bases: ValidationModel[Tuple[int, …]]

A ValidationModel that validates a combination of dots in a game.

n_of_dots

The number of dots in the combination.

Type:

int

n_of_colors

The number of colors available for the dots.

Type:

int

validate_value(value: Any) Tuple[int, ...][source]

Validates the given combination and returns the validated combination.

Parameters:

value (Any) – The combination to be validated.

Returns:

The validated combination.

Return type:

Tuple[int, …]

Raises:
  • TypeValidationError – If the combination is not a tuple or list of integers.

  • RangeError – If the combination does not have the correct number of dots or the dot values are not within the valid range.

class mastermind.validation.models.valid_feedback.ValidFeedback(number_of_dots: int)[source]

Bases: ValidationModel[Tuple[int, int]]

A ValidationModel that validates the feedback for a game.

number_of_dots

The number of dots in the combination.

Type:

int

validate_arguments() None[source]

Validates the arguments used to initialize the ValidFeedback.

Raises:

RangeError – If the number_of_dots parameter is not in valid range.

validate_value(value: Any) Tuple[int, int][source]

Validates the given feedback and returns the validated feedback.

Parameters:

value (Any) – The feedback to be validated.

Returns:

The validated feedback.

Return type:

Tuple[int, int]

Raises: