Skip to content

Decimal property editor: Flexibly parse decimal value with different separators (closes #20823)#20828

Merged
Zeegaan merged 2 commits intomainfrom
v17/bugfix/decimal-parsing-on-property-editor-validation
Nov 14, 2025
Merged

Decimal property editor: Flexibly parse decimal value with different separators (closes #20823)#20828
Zeegaan merged 2 commits intomainfrom
v17/bugfix/decimal-parsing-on-property-editor-validation

Conversation

@AndyButland
Copy link
Contributor

Prerequisites

  • I have added steps to test this contribution in the description below

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.

Copilot AI review requested due to automatic review settings November 13, 2025 15:40
@AndyButland AndyButland changed the title Decimal property editor: Flexibly parse decimal value with different separators Decimal property editor: Flexibly parse decimal value with different separators (closes #20823) Nov 13, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 TryParsePropertyValue method to handle multiple numeric types explicitly before attempting string parsing
  • Added fallback to CultureInfo.CurrentCulture for string parsing when InvariantCulture fails
  • 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

Copy link
Member

@Zeegaan Zeegaan left a comment

Choose a reason for hiding this comment

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

Works like a charm 🚀

@Zeegaan Zeegaan merged commit a4438e5 into main Nov 14, 2025
26 checks passed
@Zeegaan Zeegaan deleted the v17/bugfix/decimal-parsing-on-property-editor-validation branch November 14, 2025 01:20
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.

Decimal property editor disregards decimal value

2 participants