Indicio-tech / pydid

Python library for validating, constructing, and representing DIDs and DID Documents
Apache License 2.0
11 stars 12 forks source link

Allow list or string as service type + test cases #82

Closed PatStLouis closed 9 months ago

PatStLouis commented 9 months ago

Addresses #81

@dbluhm Please let me know if anything else needs to be added here!

dbluhm commented 9 months ago

A few failing tests to take care of

PatStLouis commented 9 months ago

I removed the invalid services I added as they weren't handled properly, I left the valid service using an array.

I was expecting the following types to be rejected but they are not at the moment: True, "", "Some type".

Since this is out of scope for this PR I will leave it as so. Perhaps it would be interesting to consider updating to pydantic 2.0.3+ in the future if there is a need for more strict field validation and introduce field_validators. Field validators would allow to make more interesting validation such as ensuring there is no space in a string, validating the length of an array, etc...

Let me know if this is satisfactory

dbluhm commented 9 months ago

It's possible to do the same with Pydantic 1.x but it would be nice to move to 2.0 regardless. I'm satisfied with these checks for now. Thanks for the contribution!