Created
April 16, 2016 09:15
-
-
Save namelos/dd07ca3a3a8d131c5d20b8fe8c4b2ed1 to your computer and use it in GitHub Desktop.
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
type Input<InputType, Validator> = { | |
value: InputType | |
default: InputType | |
description: Description | |
validation: Validator | |
} | |
type InputType = (TextField | TextArea | CheckBox | CheckGroup<CheckBox> | Radio | Select) | |
type Description = string | |
type ErrorMessage = string | |
type Validation<ValidationType> = { | |
value: ValidationType | |
error: ErrorMessage | |
} | |
type Required = Validation<boolean> | |
type Maximum = Validation<number> | |
type Minimum = Validation<number> | |
type Min = Validation<number> | |
type Max = Validation<number> | |
type TextField = Input<(string | number), { | |
require: Required | |
maximum: Maximum | |
minimum: Minimum | |
min: Min | |
max: Max | |
}> | |
type TextArea = Input<string, { | |
require: Required | |
maximum: Maximum | |
minimum: Minimum | |
}> | |
type CheckBox = Input<(boolean | string), { | |
require: Required | |
maximum: Maximum | |
minimum: Minimum | |
}> | |
type CheckGroup<CheckBox> = Input<CheckBox, { | |
require: Required | |
maximum: Maximum | |
minimum: Minimum | |
}> | |
type Radio = Input<(number | Array<(string| number)>), { | |
require: Required | |
}> | |
type Select = Input<(number | Array<(string| number)>), { | |
require: Required | |
}> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment