You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sch=Schema({
'nameservers': Or(
And(str, valid_ip, Use(lambdax: [x])), # manage list conversion when string is providedAnd([str], lambdax: all([valid_ip(it) foritinx])) # check that all ip are valid in the list in case of list. Use Const( lambda ... , error='nice error message') to display a usefull error message
)})
print(sch.validate({'nameservers': ['192.168.0.1']}))
print(sch.validate({'nameservers': ['192.168.0.1', '192.168.0.2']}))
print(sch.validate({'nameservers': '192.168.0.1'}))
Greetings!
We have the use-case that some values should be translated to lists if only one value is supplied.
Example:
Is there a clean way to validate the return-values that were translated by calling
Use()
?As a workaround we can, of course, create a separate
Use
function for every different use-case. Per example:Use(list_of_ips)
The text was updated successfully, but these errors were encountered: