Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix infinity error
  • Loading branch information
Luncher committed May 23, 2022
commit dbba8f53f1a160d6523f7c44f4e9edc971127d36
2 changes: 1 addition & 1 deletion src/adapter/v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Upgrader<T extends v2.ComposibleValidatable<unknown, V>, V> extends BaseSt

@computed get value() { return this.stateV2.value }
@computed get touched() { return this.stateV2.dirty }
@computed get rawError() {
@computed get rawError() {
return getV3OwnError(this.stateV2)
}
@computed get error() { return this.stateV2.error }
Expand Down
8 changes: 3 additions & 5 deletions src/debouncedState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } from './utils'
import { debounce, isPassed } from './utils'

const defaultDelay = 200 // ms

/** Information synced from original state */
type OriginalInfo<V> = Pick<IState<V>, 'activated' | 'touched' | 'error' | 'ownError' | 'hasError' | 'rawError'>
type OriginalInfo<V> = Pick<IState<V>, 'activated' | 'touched' | 'error' | 'rawError'>

/**
* The state for debounce purpose.
Expand Down Expand Up @@ -42,8 +42,6 @@ export class DebouncedState<S extends IState<V>, V = ValueOf<S>> extends Validat
activated: this.$.activated,
touched: this.$.touched,
error: this.$.error,
ownError: this.$.ownError,
hasError: this.$.hasError,
rawError: this.$.rawError
}
}
Expand All @@ -54,7 +52,7 @@ export class DebouncedState<S extends IState<V>, V = ValueOf<S>> extends Validat

@override override get rawError() {
if (this.disabled) return undefined
if (this.validationResult) return this.validationResult
if (!isPassed(this.validationResult)) return this.validationResult
return this.original.rawError
}

Expand Down