Update validation logic for validator v0.17+ compatibility #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello! I've been following your tutorial and found it very helpful. I noticed that for new users, the project fails to compile due to a breaking change in a newer version of the
validatorcrate.The Problem
The project's
Cargo.tomlspecifiesvalidator = "0.16.1", which works correctly. However, a user starting the project today would likely get a newer version (e.g.,0.20.0) by default.Starting with
validatorv0.17.0, duplicate validation attributes on a single field are no longer allowed and will cause aDuplicate field 'length'compilation error. This affects several of the password fields inaxum_auth_backend/src/dtos.rswhich use twolengthattributes.There was also a minor field name mismatch, where
FilterUserDtousednamewhile theUsermodel usedusername.The Solution
This pull request updates the validation rules to conform to the modern API of the
validatorcrate by removing redundantlengthattributes. It also corrects thename/usernamefield mismatch for consistency.Example Change:
Benefits
This update will help keep your excellent tutorial accessible to everyone. Thanks!