From fb19050c757b92deb5f0e718f985aa85fb8c3593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrej=20=C4=8Ci=C5=BEm=C3=A1rik?= Date: Tue, 17 Jan 2023 10:51:01 +0100 Subject: [PATCH 1/2] Fixed breaking change for BusinessPack --- src/Framework/Framework/Controls/Validator.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Framework/Framework/Controls/Validator.cs b/src/Framework/Framework/Controls/Validator.cs index ffa5183f40..dd55a55214 100644 --- a/src/Framework/Framework/Controls/Validator.cs +++ b/src/Framework/Framework/Controls/Validator.cs @@ -99,7 +99,9 @@ private static void AddValidatedValue(IHtmlWriter writer, IDotvvmRequestContext } else { - throw new DotvvmControlException($"Could not resolve {nameof(ValueProperty)} to a valid value binding."); + // Could not resolve ValueProperty to a valid value binding + // Note: this can sometimes happen when using AutomaticValidation in BusinessPack + writer.AddKnockoutDataBind(validationDataBindName, control, ValueProperty, renderEvenInServerRenderingMode: true); } // render options From 0ee2368519be704390c87804f03961bd2f972e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrej=20=C4=8Ci=C5=BEm=C3=A1rik?= Date: Wed, 18 Jan 2023 14:49:01 +0100 Subject: [PATCH 2/2] Removed unnecessary data-bind and added check for hard-coded values --- src/Framework/Framework/Controls/Validator.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Framework/Framework/Controls/Validator.cs b/src/Framework/Framework/Controls/Validator.cs index dd55a55214..b824115b28 100644 --- a/src/Framework/Framework/Controls/Validator.cs +++ b/src/Framework/Framework/Controls/Validator.cs @@ -99,9 +99,15 @@ private static void AddValidatedValue(IHtmlWriter writer, IDotvvmRequestContext } else { - // Could not resolve ValueProperty to a valid value binding - // Note: this can sometimes happen when using AutomaticValidation in BusinessPack - writer.AddKnockoutDataBind(validationDataBindName, control, ValueProperty, renderEvenInServerRenderingMode: true); + // Note: ValueProperty can sometimes contain null (BusinessPack depends on this behaviour) + // However, it certainly should not contain hard-coded values + + var valueRaw = control.GetValueRaw(ValueProperty); + if (valueRaw != null) + { + // There is a hard-coded value in the ValueProperty + throw new DotvvmControlException($"{nameof(ValueProperty)} can not contain a hard-coded value."); + } } // render options