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

fix: strictbytes-max-length #4383

Merged
merged 3 commits into from Aug 16, 2022

Conversation

JeanArhancet
Copy link
Contributor

@JeanArhancet JeanArhancet commented Aug 16, 2022

Change Summary

Related issue number

fix #4380

Checklist

  • Unit tests for the changes exist
  • Tests pass on CI and coverage remains at 100%
  • Documentation reflects the changes where applicable
  • changes/<pull request or issue id>-<github username>.md file added describing change
    (see changes/README.md for details)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

@JeanArhancet
Copy link
Contributor Author

please review

u: StrictBytes = Field(..., max_length=5)

with pytest.raises(ValidationError, match='byte type expected'):
Model(u=123)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a test with a byte (to make strictness pass) with

  • short length to raise ValidationError
  • long length to pass
    ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, What do you think?

@JeanArhancet
Copy link
Contributor Author

please review

Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
Copy link
Member

@hramezani hramezani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@PrettyWood merge if you're happy.

@PrettyWood PrettyWood merged commit 67b653f into pydantic:master Aug 16, 2022
@JeanArhancet JeanArhancet deleted the fix/strictbytes-max-length branch August 20, 2022 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StrictBytes does not raise ValidationError when max_length is present in Field
4 participants