Components: Forms and validation#7614
Conversation
|
@natemcmaster Is it OK for me to put back the dependency on |
|
@SteveSandersonMS See https://github.com/aspnet/AspNetCore/blob/master/docs/ReferenceResolution.md#example-adding-a-new-dependency. I removed it because projects don't need this |
src/Components/Components/src/Forms/InputComponents/InputNumber.cs
Outdated
Show resolved
Hide resolved
src/Components/Components/src/Forms/InputComponents/InputNumber.cs
Outdated
Show resolved
Hide resolved
src/Components/Components/src/Forms/EditContextDataAnnotationsExtensions.cs
Show resolved
Hide resolved
e8397d2 to
3cc40e4
Compare
|
@natemcmaster Changed as requested. Please leave a 5☆ review if satisfactory :) |
|
/AzurePipelines run all |
|
No pipelines are associated with this pull request. |
|
/AzurePipelines Go home, you're drunk. |
Command 'Go' is not supported by Azure Pipelines.
Supported commands
help:
Get descriptions, examples and documentation about supported commands
Example: help "command_name"
run:
Run all pipelines or a specific pipeline for this repository using a comment. Use
this command by itself to trigger all related pipelines, or specify a pipeline
to run.
Example: "run" or "run pipeline_name"
See additional documentation.
|
boom |
OK, this is a pretty massive PR, so @rynowak / @javiercn / @pranavkm - would any of you like me to give you a 30-minute tour of the changes and new features? Or if you prefer just to dive into the code that's completely fine with me too.
Features
EditContext- this tracks metadata about an edit process (e.g., what's been modified, current validation messages, etc.). It doesn't do any actual validation itself, but rather has an API designed to let external systems hook into it. External things can get notification about when fields are edited so they can choose to validate if they want.EditForm- this creates anEditContextfor you and cascades it down to contents. It also provides extra events (OnValidSubmit,OnInvalidSubmit, though you can still useOnSubmitdirectly if you want to trigger the validation yourself based on your own lifecycle design).DataAnnotationsValidator- this attaches data annotations support to anEditContextValidationSummary- like the one in MVCInputText,InputCheckbox,InputSelect, etc.). These provide default behavior of validating on edit and changing their CSS class to reflect field state. Some of them have useful parsing logic (e.g.,InputDateandInputNumberhandle unparseable values gracefully by registering them as validation errors). The relevant ones also support nullability of the target field (e.g.,int?).For usage examples, see the new test cases in the E2E BasicTestApp:
Still to do for preview 3
Make the build pass. Need to check with @natemcmaster what's needed to deal with the platform manifest error.Should be OK now.Rebase onDonemaster. This is tricky because in the last few days, the repo stopped taking a dependency on DataAnnotations, so I need to put that back. And first I need approval to join the darc group, etc.E2E tests. The test cases themselves are implemented - I just haven't written the Selenium automation for them yet.DoneMaybe implement aImplemented.ValidationMessagecomponent, which would be trivial. Or developers can implement it themseles. By design, these sorts of things don't require priviledged access to any internal APIs.Remove the manual usages ofNot waiting for this.*Expressionfrom the test cases once this enhancement gets merged into Razor: Components that accept bind-Something can request SomethingExpression razor#213Further enhancements planned for after preview 3
<DataAnnotationsValidator>in everyEditFormif that's what you're using.maxlengthonInputTextjust aren't supported (or at least, you have to subclassInputTextand put that feature on your subclass, which is inconvenient).