Hi Åukasz,
I'll assume that 'validators.OneOf[1,2,3,4]' was a typo and that you meant
validators.OneOf([1,2,3,4]).
You need to combine two validators using either All or Pipe (see
http://www.formencode.org/en/latest/modules/compound.html).
Post by Lukasz Michalskifrom formencode import validators, Pipe
pv = Pipe(validators.Int(), validators.OneOf([1,2,3,4]))
pv.to_python('1')
1
All is the same but you need to put the validators in reverse order that
Post by Lukasz Michalskifrom formencode import validators, All
av = All(validators.OneOf([1,2,3,4]), validators.Int())
av.to_python('1')
1
Post by Lukasz Michalskifrom formencode import Invalid
... av.to_python('b')
... except Invalid, e:
... print e
...
Please enter an integer value
-Chris
Post by Lukasz MichalskiHi,
Does anyone have an example how to validate set of integers from input
string?
validators.OneOf[1,2,3,4,5] throws an exception when '1' is passed.
validators.Int() AFAIK does not allow to specify set of valid values.
Is there any method to combine those two?
Thanks,
Åukasz
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
FormEncode-discuss mailing list
https://lists.sourceforge.net/lists/listinfo/formencode-discuss
--
Christopher Lambacher
***@kateandchris.net