Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default keyword #4

Closed
LarryEitel opened this issue Jan 25, 2013 · 3 comments
Closed

default keyword #4

LarryEitel opened this issue Jan 25, 2013 · 3 comments

Comments

@LarryEitel
Copy link

Although not part of validation, where would be best place to specify default values?

@nicolaiarocci
Copy link
Member

As you say, default values have nothing to do with validation. Cerberus does not edit the dictionary in any way, therefore could not provide this service. Defaults should be handled before validation, maybe by recurring to the handy setdefault(docs) method.

Now, if your intended context was the Eve REST API Framework then yes, default values for collection schemas would probably make for a nice feature. Consider opening a feature request issue @ Eve repo in that case.

@nicolaiarocci
Copy link
Member

I've been thinking about this and actually ended up implementing a default constraint for Cerberus. It is actually very similar to required since for the purpose of validation a default value simply means that the field must be present, and it must carry a value (string fields cannot be empty). This will allow for a richer grammar when defining schemas, and pre-processors will have an easier game at supporting default values (think Eve). Stay tuned.

@nicolaiarocci
Copy link
Member

On second thought, I went with a different approach (transparent rules). a6d4fba

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants