(input, spec)
| 226 | |
| 227 | @staticmethod |
| 228 | def validate(input, spec): |
| 229 | if not input and (not spec.get("required", None) or spec.get("default", None)): |
| 230 | return |
| 231 | |
| 232 | if not input.isdigit(): |
| 233 | raise validation.ValidationError(len(input), "Not a number") |
| 234 | |
| 235 | enum = spec.get("enum") |
| 236 | try: |
| 237 | enum[int(input)] |
| 238 | except IndexError: |
| 239 | raise validation.ValidationError(len(input), "Out of bounds") |
| 240 | |
| 241 | def _construct_template(self): |
| 242 | self.template = "{0}: " |