Skip to content

Latest commit

 

History

History
293 lines (179 loc) · 6.95 KB

README.md

File metadata and controls

293 lines (179 loc) · 6.95 KB

dumba

dumba

Table of contents

Classes

Type aliases

Variables

Functions

Type aliases

CreateFieldData

Ƭ CreateFieldData<T>: Object

Data for the createField factory

example Depends on

const schema = {
  info:{
    name:{}
    nick:{
      dependsOn:'info.name'
    }
  }
}

Type parameters

Name Description
T type of value for the Field

Type declaration

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> -

Defined in

field-factory.ts:21


FieldResult

Ƭ FieldResult<T>: Object

Result of the Field validation

Type parameters

Name Type Description
T any value of the Field

Type declaration

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

Defined in

field.ts:10


FormConfig

Ƭ FormConfig: Object

Type declaration

Name Type
removeDisabled? boolean
validateBeforeSubmit? boolean

Defined in

form.ts:36


RunnerResult

Ƭ RunnerResult: Object

Result of running all Validations

Type declaration

Name Type Description
errors null | string[] error messages
value any value that was validated against

Defined in

runner.ts:7


SchemaResults

Ƭ 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

Type parameters

Name
T

Defined in

form.ts:28


SchemaValues

Ƭ 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

Type parameters

Name
T

Defined in

form.ts:17


ValidationFn

Ƭ ValidationFn: (value: any, field: Field<any>, dependency?: Field<any>) => boolean | Promise<boolean> | string | Promise<string>

Type declaration

▸ (value, field, dependency?): boolean | Promise<boolean> | string | Promise<string>

Validation function signature

Parameters
Name Type Description
value any value to be validated
field Field<any> -
dependency? Field<any> -
Returns

boolean | Promise<boolean> | string | Promise<string>

Defined in

validation.ts:8

Variables

FAILED_VALIDATION_RESPONSE

Const FAILED_VALIDATION_RESPONSE: "validation_failed"

Response string that is returned when the form fails validation

Defined in

form.ts:12

Functions

createField

createField<T>(data): Field<T>

Factory function that creates the @class Field

Type parameters

Name
T

Parameters

Name Type Description
data CreateFieldData<T> field data

Returns

Field<T>

instance of Field

Defined in

field-factory.ts:68


createValidation

createValidation(fn, msg?): Validation

Parameters

Name Type Default value
fn ValidationFn undefined
msg string Validation.defaultMessage

Returns

Validation

Defined in

validation.ts:14


getForm

getForm<T>(field): Form<T>

Gets the form Form from the passed in field

Type parameters

Name Description
T value of the Form schema

Parameters

Name Type
field Field<any>

Returns

Form<T>

Defined in

utils.ts:24