Commits

Scott Wilson  committed 3fef482

Updated the MapEqual validator and a couple of tests to use new path name style.

Also updated a doctest and removed a test of float -> decimal conversion
which behaves differently depending on python version.

  • Participants
  • Parent commits 5d8f310

Comments (0)

Files changed (4)

File flatland/validation/number.py

         self.method = method
 
     def validate(self, element, state):
-        npa = element.el(self.npa).value
-        nxx = element.el(self.nxx).value
+        npa = element.find(self.npa, single=True).value
+        nxx = element.find(self.nxx, single=True).value
 
         if self.errors_to:
-            err = element.el(self.errors_to)
+            err = element.find(self.errors_to)
         else:
             err = element
 

File flatland/validation/scalars.py

         Validator.__init__(self, **kw)
 
     def validate(self, element, state):
-        elements = [element.el(name) for name in self.field_paths]
+        elements = [element.find(name, single=True) for name in self.field_paths]
         fn = self.transform
         sample = fn(elements[0])
         if all(fn(el) == sample for el in elements[1:]):
       from flatland.validation import ValuesEqual
 
       class MyForm(flatland.Form):
-          schema = [ String('password'), String('password_again') ]
-          validators = ValuesEqual('password', 'password_again')
+          password = String
+          password_again = String
+          validators = [ValuesEqual('password', 'password_again')]
 
     .. attribute:: transform()
 

File tests/schema/test_scalars.py

                  (-123,      d('-123'),  u'-123.000000'),
                  (d(123),    d('123'),   u'123.000000'),
                  (d(-123),   d('-123'),  u'-123.000000'),
-                 (123.456,   None,       u'123.456'),
                  (u'+123',   d('123'),   u'123.000000', dict(signed=False)),
                  (u'-123',   None,       u'-123', dict(signed=False)),
                  (None,      None,       u'', {}, True)):

File tests/validation/test_scalars.py

 
 
 def test_values_equal_resolution():
-    v = ValuesEqual('x', '.sub.xx')
+    v = ValuesEqual('x', '/sub/xx')
     el = form(dict(x='a', sub=dict(xx='a')))
     assert v.validate(el, None)
 
-    v = ValuesEqual('.x', 'xx')
+    v = ValuesEqual('/x', 'xx')
     el = form(dict(x='a', sub=dict(xx='a')))
     assert v.validate(el['sub'], None)