Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where decimal property validation fails when the client and server use different decimal separators (e.g., comma vs. period). The solution adds flexible parsing logic that handles numeric types directly and falls back to culture-specific string parsing when needed.
Key changes:
- Enhanced
TryParsePropertyValuemethod to handle multiple numeric types explicitly before attempting string parsing - Added fallback to
CultureInfo.CurrentCulturefor string parsing whenInvariantCulturefails - Added unit test to verify validation works with Italian culture (comma decimal separator)
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Umbraco.Core/PropertyEditors/DecimalPropertyEditor.cs | Replaced single-line TryParsePropertyValue with comprehensive implementation that checks for decimal/double/float types, handles IFormattable with InvariantCulture, and falls back to CurrentCulture parsing; also removed an empty line |
| tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/DecimalPropertyValueEditorTests.cs | Added test case with Italian culture setting to verify validation works with different decimal separators |
tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/DecimalPropertyValueEditorTests.cs
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Prerequisites
Fixes: #20823
Description
This linked issue shows a server-side error message that appears to come about when there's a difference in decimal separators between the client and the server. I was able to replicate this via a failing unit test, that parses when the code from this PR is applied.
Testing
Verify min/max validation with the decimal property editor.