-
Notifications
You must be signed in to change notification settings - Fork 9
[RMBWEB-2780] Support for structured validation results #87
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
83cd99a
implement struct validation result
Luncher 8d68591
fix typo
Luncher f466115
restruct normalize raw error
Luncher db9f109
update state comment
Luncher 227f425
fix typo
Luncher d84c44a
remove rawError from ValidateResultWithError
Luncher 90e4499
update test case
Luncher 78f35e5
fix typo
Luncher b2f88ba
update check error condition
Luncher e5afe2a
remove debug info
Luncher 3e45f64
add test case
Luncher 511d66f
fix throw error test case
Luncher b8fb666
restruct error hierarchy
Luncher 9065ddf
restruct docs and misc
Luncher 5d56725
fix test case
Luncher 2c76ca8
update comments
Luncher a8cb353
rename _error
Luncher 031f8a1
fix override state props
Luncher ba4b45e
abstract error
Luncher dbba8f5
fix infinity error
Luncher a5ec69d
fix typo
Luncher 82e505b
fix typo
Luncher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix override state props
- Loading branch information
commit 031f8a1cbed5e82f6edfda8b07c5776672799cbd
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,12 +2,12 @@ import { action, computed, makeObservable, observable, override, reaction } from | |
| import { FieldState } from './fieldState' | ||
| import { ValidatableState } from './state' | ||
| import { IState, ValidateStatus, ValueOf } from './types' | ||
| import { debounce, isPassed, normalizeError } from './utils' | ||
| import { debounce, isPassed } from './utils' | ||
|
|
||
| const defaultDelay = 200 // ms | ||
|
|
||
| /** Infomation synced from original state */ | ||
| type OriginalInfo<V> = Pick<IState<V>, 'activated' | 'touched' | 'error' | 'ownError' | 'hasError'> | ||
| /** Information synced from original state */ | ||
| type OriginalInfo<V> = Pick<IState<V>, 'activated' | 'touched' | 'error' | 'ownError' | 'hasError' | 'rawError'> | ||
|
||
|
|
||
| /** | ||
| * The state for debounce purpose. | ||
|
|
@@ -24,7 +24,7 @@ export class DebouncedState<S extends IState<V>, V = ValueOf<S>> extends Validat | |
| /** Debounced version of original value */ | ||
| @observable.ref value!: V | ||
|
|
||
| /** Orignal information, same version with current `value` */ | ||
| /** Original information, same version with current `value` */ | ||
| @observable.ref private synced!: OriginalInfo<V> | ||
|
|
||
| /** Original information for current `value` */ | ||
|
|
@@ -43,18 +43,19 @@ export class DebouncedState<S extends IState<V>, V = ValueOf<S>> extends Validat | |
| touched: this.$.touched, | ||
| error: this.$.error, | ||
| ownError: this.$.ownError, | ||
| hasError: this.$.hasError | ||
| hasError: this.$.hasError, | ||
| rawError: this.$.rawError | ||
| } | ||
| } | ||
|
|
||
| @computed get touched() { | ||
| return this.original.touched | ||
| } | ||
|
|
||
| @override override get ownError() { | ||
| @override override get rawError() { | ||
| if (this.disabled) return undefined | ||
| if (this.rawError) return normalizeError(this.rawError) | ||
| return this.original.ownError | ||
| if (this.validationResult) return this.validationResult | ||
|
||
| return this.original.rawError | ||
| } | ||
|
|
||
| @override override get error() { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
多了个空格?以及第 30 行也多了个