You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the expected way of handling validation of a form field that is of type <input type="file">? Suppose that the form is bound to a model that has such a field and the form should display a validation message, when certain criteria is nto met, e.g. the file size exceeds a limit or the file has an invalid extension. Furthermore, what is the expected type of the model field that corresponds to <input type="file"> as things like IFormFIle
fail with an exception (this is expected, but what should be the correct type):
The type 'Microsoft.AspNetCore.Http.IFormFile' does not have an
associated TypeConverter that supports conversion from a string.
Apply 'TypeConverterAttribute' to the type to register a converter.
Currently, there isn't a built in<InputFile> component and the blog post from @SteveSandersonMS doesn't mention form validation. In addition, will there be any built-in support for anti-forgery tokens as it is the case with MVC forms or should this be manually handled by the developer?
Will there be a difference whether wasm or server-side blazor is used?
Additional context
Building a custom <InputFile> component requires some type of validation when used in a form. Using a fully custom validation, e.g. manually displaying a message is possible, but this does not work with validation attributes at all.
The text was updated successfully, but these errors were encountered:
Hi @Stamo-Gochev, IFormFile is not not part of the Blazor programming model and is not supported in the context of a Blazor component. You'll have to use JSInterop to read the file extension and apply your own validation.
What is the expected way of handling validation of a form field that is of type
<input type="file">
? Suppose that the form is bound to a model that has such a field and the form should display a validation message, when certain criteria is nto met, e.g. the file size exceeds a limit or the file has an invalid extension. Furthermore, what is the expected type of the model field that corresponds to<input type="file">
as things likeIFormFIle
fail with an exception (this is expected, but what should be the correct type):
Currently, there isn't a built in
<InputFile>
component and the blog post from @SteveSandersonMS doesn't mention form validation. In addition, will there be any built-in support for anti-forgery tokens as it is the case with MVC forms or should this be manually handled by the developer?Will there be a difference whether wasm or server-side blazor is used?
Additional context
Building a custom
<InputFile>
component requires some type of validation when used in a form. Using a fully custom validation, e.g. manually displaying a message is possible, but this does not work with validation attributes at all.The text was updated successfully, but these errors were encountered: