I have a basic schema that I'm messing with to see if eve is a good match for what I need. My question is whether I can set a default value for a field by using a method, also with params would be awesome though I doubt it's possible.
Something like:
from utils import generate_token
...
'token': {
'type': 'string',
'default': generate_token,
'unique': True,
'required': True,
}
With the new release of Cerberus (0.9) I managed to find a hack into this matter and specify 'coerce' which is a callable being applied to the value before the validation takes place so I just went ahead with the following which works as I need it:
'token': {
'type': 'string',
'default': None,
'coerce': generate_token,
'unique': True,
'readonly': True
}