Skip to content

Latest commit

 

History

History
195 lines (102 loc) · 2.66 KB

File metadata and controls

195 lines (102 loc) · 2.66 KB

sapi-pro


sapi-pro / ValueField

Abstract Class: ValueField<T>

Extends

Extended by

Type Parameters

T

T extends ValueType

Constructors

Constructor

new ValueField<T>(): ValueField<T>

Returns

ValueField<T>

Inherited from

BaseField.constructor

Properties

__optional

protected __optional: boolean = false


_key?

protected optional _key?: string


isValueField

readonly isValueField: true = true

Overrides

BaseField.isValueField


validators

protected validators: FieldValidator<T>[] = []

Accessors

isOptional

Get Signature

get isOptional(): boolean

Returns

boolean

Methods

build()

abstract build(form, t): void

Parameters

form

ModalFormData

t

UniversalTranslator

Returns

void

Inherited from

BaseField.build


getKey()

getKey(): string | undefined

Returns

string | undefined


key()

key(key): this

Parameters

key

string

Returns

this


optional()

optional(): ValueField<T> & object

Returns

ValueField<T> & object


parse()

abstract parse(raw): T | undefined

将 UI 原始值解析为目标类型。

  • 如果是基础类型错误(如期待数字却得到布尔),抛出对应类型的 ParseError。
  • 如果是数值格式错误(如 TextField 输入了非数字),抛出格式 ParseError。

Parameters

raw

ValueType

Returns

T | undefined


validate()

validate(value): string | LangText | undefined

执行校验链。

  • isEmpty 判定:undefined 或空字符串。
  • 如果必填且为空,返回 Field_Empty 错误。

Parameters

value

T | undefined

Returns

string | LangText | undefined


validator()

validator(...v): ValueField<T>

Parameters

v

...FieldValidator<T>[]

Returns

ValueField<T>