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

Nonable fields #44

Closed
smarie opened this issue Oct 23, 2019 · 2 comments
Closed

Nonable fields #44

smarie opened this issue Oct 23, 2019 · 2 comments

Comments

@smarie
Copy link
Owner

smarie commented Oct 23, 2019

From #43 :

As of now we seem to have to explicitly declare optionality for the "check type" to skip the type validation in case of a nullable field.

For example:

from typing import Optional

class A:
     field1: Optional[int] = field(check_type=True, default=None)
     field2: Optional[int] = field(check_type=True)

Note that this is completely independent from the fact that a field is optional or mandatory. However the usual python behaviour for typing is to consider nullable all arguments that have a None default value, see https://stackoverflow.com/a/57390124/7262247.

@smarie
Copy link
Owner Author

smarie commented Oct 23, 2019

also we should make the value validators (another feature of pyfields) skip validation in case None is passed.

@smarie smarie changed the title Nullable fields Nonable fields Oct 24, 2019
@smarie smarie closed this as completed in 2e818f7 Oct 25, 2019
@devashishshankar
Copy link

Thanks

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

No branches or pull requests

2 participants