Hi, 

We have a CrudRestControllerConfig and define our defaultCrudRestController 
with __form_options__.

Suppose we have a field 'my_field' and it's included in the 
__form_options__'s __require_fields__ directive:

...
'__require_fields__': ['my_field'],
...


Then if that field is left blank, TG2 will show an error and tell the user 
to 'Please enter a value'.

However, we have defined a custom validator for that field that looks 
something like this:

class MyValidator(FancyValidator):

    def __init__(self, *args, **kw):

        FancyValidator.__init__(self, *args, **kw)


    messages = dict(MyError=_('MyField Error'))


    def _validate_python(self, value, state):


        if value is None or not isinstance(value, str):

            raise Invalid(self.message('MyError', state), value, state)


        if not is_my_value_valid(value):

            raise Invalid(self.message('MyError', state), value, state)


If the field is left empty, the __require_fields__ mechanism doesn't seem 
to get invoked and the validator is not called either.  

The empty value is accepted without issue. 

Is this a known issue or am I doing something foolish?

Many thanks

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/turbogears.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/turbogears/e2f2cf9a-4423-4575-ab8e-c7acff5a824e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to