Last active
May 29, 2019 20:04
-
-
Save amcgregor/ae3f6dc61a84abba6b918d74938e4ee4 to your computer and use it in GitHub Desktop.
This file contains 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
from marrow.schema import Attribute | |
from marrow.schema.validate import Validator | |
from marrow.schama.validate.exc import Concern | |
class EqualsOther(Validator): | |
"""Ensure the value used matches an existing value from another attribute on the same object.""" | |
other = Attribute() | |
def validate(self, value, context): | |
other = getattr(context, self.other, None) | |
if value != other: | |
raise Concern("Values do not match.") | |
return value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment