Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OF#3257] Check BSN in cosign #43

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions src/formio/components/cosign.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {OFExtensions, StrictComponentSchema} from '..';
import {EmailInputSchema} from './email';
import {InputComponentSchema, OFExtensions, StrictComponentSchema} from '..';

type TranslatableKeys = 'label' | 'description';

Expand Down Expand Up @@ -43,7 +42,20 @@ export interface CosignV1ComponentSchema extends Omit<CosignV1InputSchema, KeysT
authPlugin: string; // plugin identifiers in the backend are dynamic
}

type V2KeysToOmit = 'hideLabel' | 'disabled' | 'placeholder';
type Validator = 'required';

export interface CosignData {
email: string;
bsn?: string;
}

type TranslatableKeysCosignV2 = TranslatableKeys | 'tooltip';

export type CosignV2InputSchema = InputComponentSchema<
CosignData,
Validator,
TranslatableKeysCosignV2
>;

/**
* The cosign component type, otherwise known as 'Cosign'.
Expand All @@ -57,9 +69,8 @@ type V2KeysToOmit = 'hideLabel' | 'disabled' | 'placeholder';
* @group Form.io components
* @category Concrete types
*/
export interface CosignV2ComponentSchema extends Omit<EmailInputSchema, V2KeysToOmit> {
export interface CosignV2ComponentSchema
extends Omit<CosignV2InputSchema, 'hideLabel' | 'placeholder' | 'disabled' | 'validateOn'> {
type: 'cosign';
validateOn: 'blur';
defaultValue?: string; // no multiple support, so must always be a single string
autocomplete?: string;
checkBsn: boolean;
}
13 changes: 6 additions & 7 deletions test-d/formio/components/cosign-v2.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ import {CosignV2ComponentSchema} from '../../../lib/';
expectAssignable<CosignV2ComponentSchema>({
id: 'yejak',
type: 'cosign',
validateOn: 'blur',
key: 'someCoSign',
label: 'Some cosign',
checkBsn: true,
});

// full, correct schema
expectAssignable<CosignV2ComponentSchema>({
id: 'yejak',
type: 'cosign',
validateOn: 'blur',
// basic tab in builder form
label: 'Some cosign',
key: 'someCoSign',
Expand All @@ -27,8 +26,11 @@ expectAssignable<CosignV2ComponentSchema>({
hidden: false,
clearOnHide: true,
isSensitiveData: true,
defaultValue: '',
autocomplete: 'email',
defaultValue: {
bsn: '',
email: ''
},
checkBsn: false,
// advanced tab in builder form
conditional: {
show: undefined,
Expand Down Expand Up @@ -84,15 +86,13 @@ expectNotAssignable<CosignV2ComponentSchema>({
expectNotAssignable<CosignV2ComponentSchema>({
id: 'yejak',
type: 'cosign' as const,
validateOn: 'blur' as const,
key: 'someCoSign',
label: 'Some cosign',
multiple: true as boolean,
});
expectNotAssignable<CosignV2ComponentSchema>({
id: 'yejak',
type: 'cosign' as const,
validateOn: 'blur' as const,
key: 'someCoSign',
label: 'Some cosign',
defaultValue: [],
Expand All @@ -103,7 +103,6 @@ expectNotAssignable<CosignV2ComponentSchema>({
expectNotAssignable<CosignV2ComponentSchema>({
id: 'yejak',
type: 'cosign' as const,
validateOn: 'blur' as const,
key: 'someCoSign',
label: 'Some cosign',
confirmationRecipient: true,
Expand Down
Loading