What does the EditorRequired attribute on a [Parameter] enforce, and when is it checked?
Last updated
[EditorRequired]marks a[Parameter]as mandatory, producing compiler warningRZ2012when it's omitted in Razor markup.It is only checked for markup usage, not for components created dynamically (e.g. via
RenderTreeBuilderor reflection).It warns about omission only and does not stop an explicit
null, so still validate critical values yourself.
- https://www.ssw.com.au/rules/editor-required-blazor-component-parameters
- https://learn.microsoft.com/en-us/aspnet/core/blazor/components/?view=aspnetcore-10.0
- https://code-maze.com/blazor-webassembly-required-parameters/
- https://learn.microsoft.com/en-us/aspnet/core/blazor/components/dynamiccomponent?view=aspnetcore-10.0