Skip to content

Commit

Permalink
Removed unnecessary data-bind and added check for hard-coded values
Browse files Browse the repository at this point in the history
  • Loading branch information
acizmarik committed Jan 18, 2023
1 parent fb19050 commit 0ee2368
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Framework/Framework/Controls/Validator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0ee2368

Please sign in to comment.