feat: duration string parser #73

Merged
JCHacking merged 2 commits from string-duration into main 2025-12-06 19:53:27 +00:00
JCHacking commented 2025-12-01 16:40:22 +00:00 (Migrated from github.com)

To implement this, the following alternatives have been considered:

  • Create our own parser
  • Use isodate
  • Use pydantic

We have opted to use pydantic because, as it is a mandatory dependency and is already integrated, there is no point in complicating things.

To implement this, the following alternatives have been considered: - Create our own parser - Use isodate - Use pydantic We have opted to use pydantic because, as it is a mandatory dependency and is already integrated, there is no point in complicating things.
JCHacking commented 2025-12-04 22:42:16 +00:00 (Migrated from github.com)

Hi @HideyoshiNakazone

It seems that with this change, the custom error is not thrown when an example is not valid for the given type, since pydantic.ValidationError is thrown first.

Should the error in StringTypeParser.from_properties_impl be ignored since it is subsequently checked in GenericTypeParser.from_properties?
Or how should we approach this case?

Hi @HideyoshiNakazone It seems that with this change, the custom error is not thrown when an example is not valid for the given type, since pydantic.ValidationError is thrown first. Should the error in StringTypeParser.from_properties_impl be ignored since it is subsequently checked in GenericTypeParser.from_properties? Or how should we approach this case?
codecov[bot] commented 2025-12-05 23:15:15 +00:00 (Migrated from github.com)

Codecov Report

All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

## [Codecov](https://app.codecov.io/gh/HideyoshiNakazone/jambo/pull/73?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vitor+Hideyoshi) Report :white_check_mark: All modified and coverable lines are covered by tests. :loudspeaker: Thoughts on this report? [Let us know!](https://github.com/codecov/feedback/issues/255)
HideyoshiNakazone commented 2025-12-05 23:18:30 +00:00 (Migrated from github.com)

The best approach is to catch any exception and convert it into a ValidationError. Any error that occurs during schema parsing should be raised as a ValidationError, allowing users of the library to easily distinguish schema-parsing issues from Pydantic validation errors throughout their code.

The best approach is to catch any exception and convert it into a `ValidationError`. Any error that occurs during schema parsing should be raised as a `ValidationError`, allowing users of the library to easily distinguish schema-parsing issues from Pydantic validation errors throughout their code.
HideyoshiNakazone commented 2025-12-05 23:19:39 +00:00 (Migrated from github.com)

All tests are now passing, are these all the proposed changes for this PR? If so, i thinks this PR is ready to merge.

All tests are now passing, are these all the proposed changes for this PR? If so, i thinks this PR is ready to merge.
JCHacking commented 2025-12-06 10:59:59 +00:00 (Migrated from github.com)

Yeah! It was everything.

Yeah! It was everything.
HideyoshiNakazone commented 2025-12-06 19:53:23 +00:00 (Migrated from github.com)

Thanks a lot for the contribution, @JCHacking. See you next time.

Thanks a lot for the contribution, @JCHacking. See you next time.
Sign in to join this conversation.