Задать вопрос

Тел: +7 965 3737 888

485

Просмотров

0

Ответов

Validator for data

<p>This module is not aimed to replace the newforms, but I would like manually write html code,
and just need a pure validate module, so I write this, and many things may be similar with
newforms. So if you like me would only need a pure validator module, you can use it.</p>
<p>And it has some different features from newforms:</p>
<ol><li>Support validator_list parameter, so you could use it just like the old manipuator class</li>
<li>Supply easy method, such as validate_and_save(), so you can pass a request object, and 
   get a tuple result (flag, obj_or_error), if the flag is True, then the next value 
   is an object; and if the flag is False, then the next value is error message.</li>
<li>Each field has a validate_and_get method, and it'll validate first and then return the 
   result, maybe an object or error message. Just like above.</li>
<li>
<p>SplitDateTimeField is somewhat different from the newforms. For example::</p>
<p>c = SplitDateTimeField('date', 'time')
print c.validate_and_get({'date':'2006/11/30', 'time':'12:13'})</p>
<p>So the first parameter is DateField's field_name, and the second parameter is TimeField's
field_name.
5. Add yyyy/mm/dd date format support
6. Support default value of a field. You can add a default value for a field, if this field 
   is not required, and the value is <em>empty</em>, Validator will return the default value.</p>
</li>
</ol><p>This module is new, so many things could be changed.</p>

Вопрос полезен? Да0/Нет0
file_3678.py(21.5Кб)
None