-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
The requirement is to set multiple fields which have individual validators where there could be a period where the invariants are not satisfied but at the end of the "transaction", all validators are satisfied. Is there a way to get this done? If not, can we add this as an enhancement?
class Test(object):
a = field(type_hint=six.integer_types, native=False, default=2)
b = field(type_hint=six.integer_types, native=False, default=1)
@a.validator()
def validate_a(self, new_a):
return new_a == self.b * 2
@b.validator()
def validate_b(self, new_b):
return new_b == self.a / 2
t = Test()
# Start transaction
t.a = 100 # Fails because the invariant is not satisfied
t.b = 50
# End of transaction
Metadata
Metadata
Assignees
Labels
No labels