dumba
Ƭ CreateFieldData<T
>: Object
Data for the createField factory
example
Depends on
const schema = {
info:{
name:{}
nick:{
dependsOn:'info.name'
}
}
}
Name | Description |
---|---|
T |
type of value for the Field |
Name | Type | Description |
---|---|---|
bailEarly? |
boolean |
return as soon as first validation returns error |
delay? |
number |
delay for running the validations |
dependsOn? |
string | string [] |
path to fields that current field should depend on |
disabled? |
boolean |
if field is disabled |
validations? |
Validation [] | Validation |
array of Validation to be used for validating the field |
value |
T |
value of the field |
parseValue? |
(data : any , field : Field <T >) => any |
function that can intercept Field.onChange and return a custom value |
shouldDisable? |
(value : any , field : Field <any >, dependency? : Field <any >) => boolean | Promise <boolean > |
- |
Ƭ FieldResult<T
>: Object
Result of the Field validation
Name | Type | Description |
---|---|---|
T |
any |
value of the Field |
Name | Type | Description |
---|---|---|
errors |
string [] | null |
error messages |
name |
string |
name of the field |
path |
string |
path of the field in the schema |
value |
T |
value of the field |
Ƭ FormConfig: Object
Name | Type |
---|---|
removeDisabled? |
boolean |
validateBeforeSubmit? |
boolean |
Ƭ RunnerResult: Object
Result of running all Validations
Name | Type | Description |
---|---|---|
errors |
null | string [] |
error messages |
value |
any |
value that was validated against |
Ƭ SchemaResults<T
>: T
extends Record
<string
, any
> ? { [key in keyof T]: T[key] extends Object ? FieldResult<T[key]["value" & keyof T[key]]> : SchemaResults<T[key]> } : T
Schema structure with validation results for the fields in the schema
Name |
---|
T |
Ƭ SchemaValues<T
>: T
extends Record
<string
, any
> ? { [key in keyof T]: T[key] extends Object ? T[key]["value" & keyof T[key]] : SchemaValues<T[key]> } : T
Schema structure with values for the fields in the schema
Name |
---|
T |
Ƭ ValidationFn: (value
: any
, field
: Field
<any
>, dependency?
: Field
<any
>) => boolean
| Promise
<boolean
> | string
| Promise
<string
>
▸ (value
, field
, dependency?
): boolean
| Promise
<boolean
> | string
| Promise
<string
>
Validation function signature
Name | Type | Description |
---|---|---|
value |
any |
value to be validated |
field |
Field <any > |
- |
dependency? |
Field <any > |
- |
boolean
| Promise
<boolean
> | string
| Promise
<string
>
• Const
FAILED_VALIDATION_RESPONSE: "validation_failed"
Response string that is returned when the form fails validation
▸ createField<T
>(data
): Field
<T
>
Factory function that creates the @class Field
Name |
---|
T |
Name | Type | Description |
---|---|---|
data |
CreateFieldData <T > |
field data |
Field
<T
>
instance of Field
▸ createValidation(fn
, msg?
): Validation
Name | Type | Default value |
---|---|---|
fn |
ValidationFn |
undefined |
msg |
string |
Validation.defaultMessage |
▸ getForm<T
>(field
): Form
<T
>
Gets the form Form from the passed in field
Name | Description |
---|---|
T |
value of the Form schema |
Name | Type |
---|---|
field |
Field <any > |
Form
<T
>