-
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.
Merge pull request #55 from open-formulieren/feature/4546-soft-requir…
…ed-validation Soft required validation
- Loading branch information
Showing
6 changed files
with
79 additions
and
2 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
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,45 @@ | ||
import {LayoutComponentSchema, OFExtensions} from '..'; | ||
|
||
type TranslatableKeys = 'html'; | ||
|
||
/** | ||
* The softRequiredErrors component schema. It's a variation on the WYSIWYG content | ||
* component. | ||
* | ||
* Any validation errors related to soft-required fields (the fields are required but | ||
* don't block progressing in the form and are therefore mostly informational/warnings) | ||
* are displayed here. The form designer can control the body text, and the SDK will | ||
* then interpolate the actual field labels that violate the requirement(s). If there | ||
* are no errors, the component is not to be displayed. | ||
* | ||
* @group Form.io components | ||
* @category Concrete types | ||
*/ | ||
export interface SoftRequiredErrorsComponentSchema | ||
extends Omit< | ||
LayoutComponentSchema<never>, | ||
| 'conditional' | ||
| 'tooltip' | ||
| 'multiple' | ||
| 'defaultValue' | ||
| 'clearOnHide' | ||
| 'validate' | ||
| 'errors' | ||
| 'description' | ||
| 'hidden' | ||
| 'hideLabel' | ||
| 'disabled' | ||
| 'widget' | ||
| 'validateOn' | ||
| 'placeholder' | ||
>, | ||
Omit<OFExtensions<TranslatableKeys>, 'registration' | 'isSensitiveData'> { | ||
id: string; | ||
key: string; | ||
type: 'softRequiredErrors'; | ||
/** | ||
* Even though the label is present, it is typically not displayed anywhere. | ||
*/ | ||
html: string; | ||
label?: string; | ||
} |
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,28 @@ | ||
import {expectAssignable} from 'tsd'; | ||
|
||
import {SoftRequiredErrorsComponentSchema} from '../../../lib'; | ||
|
||
// Minimal schema | ||
expectAssignable<SoftRequiredErrorsComponentSchema>({ | ||
type: 'softRequiredErrors', | ||
id: 'iitral8', | ||
key: 'someKey', | ||
label: 'Ignored', | ||
html: '<div>Will need to be properly {{ field_errors }} structured.</div>', | ||
}); | ||
|
||
// With translations | ||
expectAssignable<SoftRequiredErrorsComponentSchema>({ | ||
type: 'softRequiredErrors', | ||
id: 'iitral8', | ||
key: 'someKey', | ||
label: 'Ignored', | ||
html: '<div>Will need to be properly {{ field_errors }} structured.</div>', | ||
openForms: { | ||
translations: { | ||
nl: { | ||
html: '<div>NL translation</div>', | ||
}, | ||
}, | ||
}, | ||
}); |