-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Components: Forms and validation #7614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⭐️ ⭐️ ⭐️ ⭐️ ⭐️
/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 anEditContext
for you and cascades it down to contents. It also provides extra events (OnValidSubmit
,OnInvalidSubmit
, though you can still useOnSubmit
directly if you want to trigger the validation yourself based on your own lifecycle design).DataAnnotationsValidator
- this attaches data annotations support to anEditContext
ValidationSummary
- 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.,InputDate
andInputNumber
handle 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.ValidationMessage
component, 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.*Expression
from 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 everyEditForm
if that's what you're using.maxlength
onInputText
just aren't supported (or at least, you have to subclassInputText
and put that feature on your subclass, which is inconvenient).