Rename Model method validator to validate

This commit is contained in:
Brian Waldon 2012-12-22 15:28:21 -08:00
parent c0e7fba643
commit 455fe617d9
1 changed files with 5 additions and 5 deletions

View File

@ -14,7 +14,7 @@ class Model(dict):
d = dict(*args, **kwargs)
try:
self.validator(d)
self.validate(d)
except exceptions.ValidationError as exc:
raise ValueError(str(exc))
else:
@ -27,7 +27,7 @@ class Model(dict):
mutation = dict(self.items())
mutation[key] = value
try:
self.validator(mutation)
self.validate(mutation)
except exceptions.ValidationError:
msg = "Unable to set '%s' to '%s'" % (key, value)
raise exceptions.InvalidOperation(msg)
@ -40,7 +40,7 @@ class Model(dict):
mutation = dict(self.items())
del mutation[key]
try:
self.validator(mutation)
self.validate(mutation)
except exceptions.ValidationError:
msg = "Unable to delete attribute '%s'" % (key)
raise exceptions.InvalidOperation(msg)
@ -77,7 +77,7 @@ class Model(dict):
mutation = dict(self.items())
mutation.update(other)
try:
self.validator(mutation)
self.validate(mutation)
except exceptions.ValidationError as exc:
raise exceptions.InvalidOperation(str(exc))
dict.update(self, other)
@ -107,7 +107,7 @@ class Model(dict):
"""Dumber version of 'patch' method - this should be deprecated"""
return copy.deepcopy(self.__dict__['changes'])
def validator(self, obj):
def validate(self, obj):
"""Apply a JSON schema to an object"""
try:
jsonschema.validate(obj, self.schema)