Skip to content
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

Refactor: change validation state to have a static valid state #132

Merged
merged 4 commits into from
Oct 16, 2020

Conversation

thargy
Copy link
Contributor

@thargy thargy commented Oct 16, 2020

What kind of change does this PR introduce?
This is discussed in #130 (comment). Essentially, with the obsolescence of Component from ValidationState then the most common 'valid' state is identical and so should be exposed as a static readonly property. This decreases memory utilisation.

What is the current behavior?
The same object risks being created repeatedly in common usage.

What is the new behavior?
Consumers can provide the static singleton instance.

What might this PR break?
All impacts relate to the now obsolete Component property, and could result in NullReferenceExceptions being thrown where consumers previously relied on the component. This is considered highly unlikely, and ultimately the property is due to be removed entirely.

  • The initial valid state created in the ObserveFor<> extension method now has a null Component property, whereas it would previously reference the supplied ValidationContext.
  • The initial valid state created in the ForValidationHelperProperty<> extension methods now have a null Component property, whereas they would previously reference the supplied viewmodel's ValidationContext.

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Other information:

Added static Valid property, for `ValidationState.Valid` as mentioned in reactiveui#130 (comment)
Updated document to use `ValidationState.Valid` as introduced in reactiveui#131
@dnfadmin
Copy link

dnfadmin commented Oct 16, 2020

CLA assistant check
All CLA requirements met.

@glennawatson glennawatson changed the title Patch 2 Refactor: change validation state to have a static valid state Oct 16, 2020
@glennawatson glennawatson merged commit ef19c5e into reactiveui:ivalidationstate Oct 16, 2020
@thargy thargy deleted the patch-2 branch October 16, 2020 23:58
worldbeater added a commit that referenced this pull request Oct 17, 2020
* Use IValidationState where possible
* The new pattern plays well with our sample app
* The new validation rule overloads
* Use the new overload in our sample app
* Additional unit tests
* Approve the API
* Update README.md (#131)
Proposed update to indicate use of `IValidationState` or `ValidationState` with `ValidationRule`.
* Refactor: change validation state to have a static valid state (#132)
* Update ValidationState.cs
Added static Valid property, for `ValidationState.Valid` as mentioned in #130 (comment)
Updated document to use `ValidationState.Valid` as introduced in #131
* Replaced construction of valid validation states with `ValidationState.Valid`.
* Added `ValidationState.Valid` to public API.
* Don't break the public ObservableValidationBase API if possible
* Use ValidationState.Valid in our sample app
Co-authored-by: Craig Dean <thargy@yahoo.com>
@reactiveui reactiveui locked as resolved and limited conversation to collaborators Nov 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants