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

is it possible to make ContactPerson be invalid without email? #189

Closed
yarikoptic opened this issue Jul 27, 2023 · 5 comments
Closed

is it possible to make ContactPerson be invalid without email? #189

yarikoptic opened this issue Jul 27, 2023 · 5 comments

Comments

@yarikoptic
Copy link
Member

We have https://github.com/dandisets/000108/blob/draft/dandiset.yaml where contact person is Lee , but he is listed without email.

- affiliation: []
  includeInCitation: true
  name: Kamentsky, Lee
  roleName:
  - dcite:ContactPerson
  schemaKey: Person
- affiliation: []
  email: [email protected]
  identifier: 0000-0002-8209-0059
  includeInCitation: true
  name: Marx, Slayton
  roleName:
  - dcite:DataManager
  - dcite:DataCurator
  - dcite:Investigation
  - dcite:ProjectMember
  - dcite:Researcher
  - dcite:Software
  - dcite:Supervision
  - dcite:Visualization
  schemaKey: Person

PS I now made @slaytonmarx to be the contact person since AFAIK Lee is no longer with the project. Please adjust if that is not true

@yarikoptic
Copy link
Member Author

@satra @candleindark - how to express such a requirement in pydantic ?

@candleindark
Copy link
Member

candleindark commented Apr 10, 2024

@satra @candleindark - how to express such a requirement in pydantic ?

Change

email: Optional[EmailStr] = Field(None, json_schema_extra={"nskey": "schema"})

to

email: Optional[EmailStr] = Field(..., json_schema_extra={"nskey": "schema"}) will do.

or

email: EmailStr = Field(..., json_schema_extra={"nskey": "schema"}) will even be better since I don't see a situation that email will be None if you make it as a required field.

General reference for this can be found at https://docs.pydantic.dev/latest/concepts/models/#required-fields.

Just be aware this change will entails a change in the schema, making the field required in the schema as well, so you may need to issue a new patch version

@yarikoptic
Copy link
Member Author

no -- it should be only if

roleName:
  - dcite:ContactPerson

@candleindark
Copy link
Member

@yarikoptic I have submitted a draft PR to provide a model level validator to ensure that a contributor acting as a contact person has an email provided. Let me know if the PR is heading to the direction of solving the problem. If it is, I will finalize the PR by adjusting the tests, etc.

@yarikoptic
Copy link
Member Author

closed by

next time @candleindark please use Closes #NUMBER in PR description.

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