This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class InputValidator: | |
| def __init__(self, prompt, cast=str, error_msg="Invalid input."): | |
| self.prompt = prompt | |
| self.cast = cast | |
| self.error_msg = error_msg | |
| self.rules = [] | |
| def add_rule(self, condition, message=None): | |
| self.rules.append((condition, message or self.error_msg)) | |
| return self # allows method chaining |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| declare -a NEW_ORDER=( | |
| "item 1" | |
| "item 2" | |
| "item 3" | |
| "cont." | |
| ) | |
| i=1 |