Skip to content

Commit 63e8b40

Browse files
committed
Updated AttributeBindingModel.Value to allow null values
In a previous update, I switched from `[NotNull, DisallowNull]` to `= default!`. These _should_ be syntactically equivalent. But they're not actually treated that way by the model binding validator, which will allow `[DisallowNull]` on a nullable type, but not on a non-nullable type. This is an issue because radio buttons, in particular, might be null—which is why we don't validate `Value` in the `AttributeBindingModelBinder`. This can be fixed by making `Value` nullable. This has some downstream effects, which will be addressed separately.
1 parent b635bf8 commit 63e8b40

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

OnTopic.Editor.AspNetCore/Models/AttributeBindingModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public AttributeBindingModel(string editorType) {
5858
/// <summary>
5959
/// The value associated with the attribute.
6060
/// </summary>
61-
public string Value { get; init; } = default!;
61+
public string? Value { get; init; } = default!;
6262

6363
/*==========================================================================================================================
6464
| GET VALUE
@@ -71,7 +71,7 @@ public AttributeBindingModel(string editorType) {
7171
/// <see cref="GetValue()"/> method is intended to be overwritten by derived versions of the <see cref="AttributeBindingModel"/>
7272
/// class, in order to provide specific serialization instructions.
7373
/// </remarks>
74-
public virtual string GetValue() => Value;
74+
public virtual string GetValue() => Value?? "";
7575

7676
} // Class
7777
} // Namespace

0 commit comments

Comments
 (0)