Hi,
I defined my own validation function:
def is_mytype(value,*options):
…
and so
val = Validator({'mytype': is_mytype })
In the spec file I have
key = mytype(“john”,”jack”,”patrick”,default=list(“john”))
If the value of this key is missing or “” in the configuration file, then an error is raised.
Only if the key is missing, then it is set to the default, here key = [ “john” ]
I would like to return in my validation function the default if value is empty, e.g.
def is_mytype(value,*options):
if not value:
return default
...
How could I do that ?
Or is it possible that the default be returned if the value is missing in the configuration file or "" ?
Thanks for the help!
Hi,
I defined my own validation function:
and so
val = Validator({'mytype': is_mytype })In the spec file I have
key = mytype(“john”,”jack”,”patrick”,default=list(“john”))If the value of this key is missing or “” in the configuration file, then an error is raised.
Only if the key is missing, then it is set to the default, here
key = [ “john” ]I would like to return in my validation function the default if
valueis empty, e.g.How could I do that ?
Or is it possible that the default be returned if the value is missing in the configuration file or "" ?
Thanks for the help!