Thanks for the reminder. What is the expected behavior? 'list:string'
only accepts strings that are not empty. Are you trying to have at
least one item in the list?
We do not have a validator to do that but can make one:

class IS_LIST_SIZE(Validator):

    def __init__(self, min=0,max=10,error_message='not in range'):
        self.min = min
        self.max=max
        self.error_message = error_message

    def __call__(self, value):
        ivalue = value
        if not isinstance(value, list):
            ivalue = [ivalue]
        if not self.min<=len(ivalue)<=self.max:
            return (ivalue, self.error_message)
        return (ivalue, None)




On Oct 23, 5:37 pm, TheSweetlink <[email protected]> wrote:
> I don't wish to irritate rather just curious to know if anyone else
> can replicate this.
>
> A SQLFORM.factory with an empty field of type='list:string' is
> submitting as passed when an IS_NOT_EMPTY() validator is used in any
> and every way possible.
>
> The very same .factory has a field type string where the same exact
> validation works as it should.  Why should my list:string not work the
> same way?
>
> Thank you in advance for your time.
>
> David

Reply via email to