-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {InputComponentSchema, MultipleCapable} from '..'; | ||
|
||
type Validator = 'required'; | ||
type TranslatableKeys = 'label' | 'description' | 'tooltip'; | ||
|
||
export type IbanInputSchema = InputComponentSchema<string, Validator, TranslatableKeys>; | ||
|
||
/** | ||
* @group Form.io components | ||
* @category Base types | ||
*/ | ||
export interface BaseIbanComponentSchema extends Omit<IbanInputSchema, 'hideLabel' | 'disabled'> { | ||
type: 'iban'; | ||
validateOn?: 'blur'; | ||
} | ||
|
||
/** | ||
* @group Form.io components | ||
* @category Concrete types | ||
*/ | ||
export type IbanComponentSchema = MultipleCapable<BaseIbanComponentSchema>; |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import {expectAssignable, expectNotAssignable} from 'tsd'; | ||
|
||
import {IbanComponentSchema} from '../../../lib'; | ||
|
||
// minimal textfield component schema | ||
expectAssignable<IbanComponentSchema>({ | ||
id: 'yejak', | ||
type: 'iban', | ||
key: 'someIban', | ||
label: 'Some IBAN', | ||
}); | ||
|
||
|
||
// multiple false and appropriate default value type | ||
expectAssignable<IbanComponentSchema>({ | ||
id: 'yejak', | ||
type: 'iban', | ||
key: 'someIban', | ||
label: 'Some IBAN', | ||
multiple: false, | ||
defaultValue: '', | ||
}); | ||
|
||
// multiple true and appropriate default value type | ||
expectAssignable<IbanComponentSchema>({ | ||
id: 'yejak', | ||
type: 'iban', | ||
key: 'someIban', | ||
label: 'Some IBAN', | ||
multiple: true, | ||
defaultValue: [''], | ||
}); | ||
|
||
// full, correct schema | ||
expectAssignable<IbanComponentSchema>({ | ||
id: 'yejak', | ||
type: 'iban', | ||
// basic tab | ||
label: 'Some IBAN', | ||
key: 'someIban', | ||
description: '', | ||
tooltip: 'A tooltip', | ||
showInSummary: true, | ||
showInEmail: false, | ||
showInPDF: true, | ||
multiple: false, | ||
hidden: false, | ||
clearOnHide: true, | ||
isSensitiveData: true, | ||
defaultValue: '', | ||
// Advanced tab | ||
conditional: { | ||
show: undefined, | ||
when: '', | ||
eq: '', | ||
}, | ||
// Validation tab | ||
validate: { | ||
required: false, | ||
plugins: [], | ||
}, | ||
translatedErrors: {nl: {required: 'Geef email.'}}, | ||
errors: {required: 'Geef email.'}, | ||
// registration tab | ||
registration: { | ||
attribute: '', | ||
}, | ||
// translations tab in builder form | ||
openForms: { | ||
translations: { | ||
nl: {label: 'foo'}, | ||
}, | ||
}, | ||
// fixed but not editable | ||
validateOn: 'blur', | ||
}); | ||
|
||
// validateOn not `blur` | ||
expectNotAssignable<IbanComponentSchema>({ | ||
id: 'yejak', | ||
type: 'iban', | ||
key: 'someIban', | ||
label: 'Some IBAN', | ||
validateOn: 'change', | ||
}); | ||
|
||
// invalid, multiple true and non-array default value | ||
expectNotAssignable<IbanComponentSchema>({ | ||
id: 'yejak', | ||
type: 'iban', | ||
key: 'someIban', | ||
label: 'Some IBAN', | ||
multiple: true, | ||
defaultValue: '', | ||
}); | ||
|
||
// invalid, multiple false and array default value | ||
expectNotAssignable<IbanComponentSchema>({ | ||
id: 'yejak', | ||
type: 'iban', | ||
key: 'someIban', | ||
label: 'Some IBAN', | ||
multiple: false, | ||
defaultValue: [''], | ||
}); | ||
|
||
// invalid, multiple true and wrong default value in array element | ||
expectNotAssignable<IbanComponentSchema>({ | ||
id: 'yejak', | ||
type: 'iban', | ||
key: 'someIban', | ||
label: 'Some IBAN', | ||
multiple: true, | ||
defaultValue: [0], | ||
}); |