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

Rewrite attribute handling code #330

Merged
merged 14 commits into from
Aug 27, 2024
Merged

Rewrite attribute handling code #330

merged 14 commits into from
Aug 27, 2024

Conversation

GREsau
Copy link
Owner

@GREsau GREsau commented Aug 27, 2024

(Yikes, I really dropped the ball on those first few commit messages 😬)

This was intended to be "just" a change to split the single Attrs type out into separate types for field/variant/containers, but it soon spiralled into a major rewrite that touched pretty much all parts of schemars_derive.

Attributes that were previously silently ignored (e.g. with/schema_with or validation attributes on structs) will now cause compile errors. Whether this is actually a breaking change is a matter of perspective, but there are definitely some other breaking changes in this PR, mostly around validation attributes:

  • Remove phone and required_nested validation attributes (they were removed from the validator crate a while ago)
  • regex and contains validation attributes must now be specified in list form regex(path = ...) rather than name/value form regex = ... (again for consistency with the current state of the validator crate). I don't like how verbose it makes them, but it will be slightly simpler once I've added support for garde-style attributes (in a future change)

…rn = ...))]`

For compatibility with the validator crate, when the `pattern` form is given a string literal, that string's contents will be parsed as an expression. This is due to the behaviour of the darling crate (TedDriggs/darling#229). I'm concerned that this behaviour may change in a future version of darling/validator, so to minimise its exposure in schemars's public API, I'm restricting its usage now.
@GREsau GREsau merged commit d07a1be into master Aug 27, 2024
8 checks passed
@GREsau GREsau deleted the attr-rewrite branch August 27, 2024 15:50
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

Successfully merging this pull request may close these issues.

1 participant