{"record":{"id":"ae0b4919f607e7a2","repo":"TheAlgorithms/Python","slug":"matrix-size-must-be-a-positive-integer","errorCode":null,"errorMessage":"Matrix size must be a positive integer.","messagePattern":"Matrix size must be a positive integer\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"matrix/matrix_based_game.py","lineNumber":61,"sourceCode":"--------\nThe script outputs the total score after processing all moves.\n\nUsage:\n-------\nRun the script and provide the required inputs as prompted.\n\n\"\"\"\n\n\ndef validate_matrix_size(size: int) -> None:\n    \"\"\"\n    >>> validate_matrix_size(-1)\n    Traceback (most recent call last):\n        ...\n    ValueError: Matrix size must be a positive integer.\n    \"\"\"\n    if not isinstance(size, int) or size <= 0:\n        raise ValueError(\"Matrix size must be a positive integer.\")\n\n\ndef validate_matrix_content(matrix: list[str], size: int) -> None:\n    \"\"\"\n    Validates that the number of elements in the matrix matches the given size.\n\n    >>> validate_matrix_content(['aaaa', 'aaaa', 'aaaa', 'aaaa'], 3)\n    Traceback (most recent call last):\n        ...\n    ValueError: The matrix dont match with size.\n    >>> validate_matrix_content(['aa%', 'aaa', 'aaa'], 3)\n    Traceback (most recent call last):\n        ...\n    ValueError: Matrix rows can only contain letters and numbers.\n    >>> validate_matrix_content(['aaa', 'aaa', 'aaaa'], 3)\n    Traceback (most recent call last):\n        ...\n    ValueError: Each row in the matrix must have exactly 3 characters.","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/matrix/matrix_based_game.py#L43-L79","documentation":"Error \"Matrix size must be a positive integer.\" thrown in TheAlgorithms/Python.","triggerScenarios":"Thrown at matrix/matrix_based_game.py:61 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a positive integer matrix size."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}