Manipulating validated data in Colander SchemaNode <p>I have a set of Colander SchemaNodes used with Pyramid/Cornice in an API. For some querystring args, a range is passed (ie <code>time=X-Y</code> means a time range from X to Y where X and Y are integers representing epochs). I currently validate this with a <code>RegEx()</code> validator to ensure an epoch or epoch range is passed in:</p> <pre><code>class TimeOrRange(SchemaNode): schema_type = String location = "querystring" description = 'Time (or range) in epochs: ssssssssss(-ssssssssss)' validator = Regex("^[0-9]{10}\-{0,1}[0-9]{0,10}$") </code></pre> <p>I then use this in a MappingSchema which is then tied to my Cornice view with <code>@view(schema=TimedThingGet)</code>:</p> <pre><code>class TimedThingGet(MappingSchema): time = TimeOrRange(missing=drop) </code></pre> <p>What I would like to do is update the return value in my <code>TimeOrRange</code> SchemaNode code so <code>time</code> in <code>TimedThingGet</code> is a tuple of time ranges. In other words, if <code>time=X-Y</code> is passed in to a <code>TimedThingGet</code> instance, then <code>time=(x, y)</code> is returned in the validated data. Similarly, if only <code>X</code> is passed in, then I want <code>Y</code> to be set to the epoch of <code>now()</code>. </p> <p>It looks like <code>set_value()</code> is the way to go, and here's where the problem get's some extra credit: </p> <ol> <li>Does <code>set_value</code> get called before or after validation?</li> <li>Does <code>set_value</code> have access to the validator such that a <code>RegEx</code> validator which creates regex groups could then be used to set my tuple: <code>time=(validated.match.group[1], validated.match.group[2])</code>?</li> </ol>