16 lines
420 B
Python
16 lines
420 B
Python
import jsonschema
|
|
|
|
|
|
class Command:
|
|
def __init__(self, name: str, schema, **kwargs):
|
|
self.name = name
|
|
self.schema = schema
|
|
self.additional_properties = kwargs
|
|
|
|
self._validator = jsonschema.validators.validator_for(
|
|
schema, default=jsonschema.validators.Draft7Validator
|
|
)(schema=schema)
|
|
|
|
def validate(self, o) -> bool:
|
|
return self._validator.is_valid(o)
|