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

Field validation and enforcement on document instantiation. #53

Open
edengreen opened this issue Oct 22, 2017 · 0 comments
Open

Field validation and enforcement on document instantiation. #53

edengreen opened this issue Oct 22, 2017 · 0 comments
Labels
2.enhancement New ideas or improvements. area:document Issues relating to the Document dictionary–compatible implementation. area:field Issues relating to Field implementations or their mechanics.

Comments

@edengreen
Copy link

edengreen commented Oct 22, 2017

Hi,
I came across your project a few days ago, looking for some alternatives to an in-house mongo-wrapper and schema-definition utility.
I was super impressed with marrow-mongo, and the entire echo-system, and I've been trying to use it in my project.

I'm trying to define a document structure with some required fields, and with type validation on each field. Unfortunately, I was not able to get any of these validations to work out of the box (see ipython snippet).

In [27]: class A(Document):
...: n = Number(required=True, validator=never)
...:

In [28]: A()
Out[28]: A()

In [29]: A(n=1)
Out[29]: A(n=1)

It looks as though the required attribute is completely ignored, and so does the validator attribute (however, I was able to enforce validation by adding the Validated mixin to the Field class, but this will force me to redefine each field type I wish to use).

Looking at the code, I wasn't able to find anywhere where these validations are enforced by default, but I'm probably missing something. I'd appreciate you help.

Thanks!

@amcgregor amcgregor added 2.enhancement New ideas or improvements. area:field Issues relating to Field implementations or their mechanics. labels Jan 22, 2018
@amcgregor amcgregor changed the title Field validation and enforcement on document instantiation Field validation and enforcement on document instantiation. Jul 28, 2021
@amcgregor amcgregor added the area:document Issues relating to the Document dictionary–compatible implementation. label Jul 28, 2021
@amcgregor amcgregor pinned this issue Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.enhancement New ideas or improvements. area:document Issues relating to the Document dictionary–compatible implementation. area:field Issues relating to Field implementations or their mechanics.
Projects
None yet
Development

No branches or pull requests

2 participants