@hmcts/ccd-case-ui-toolkit 7.4.26-pofcc-436-optional-text → 7.4.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6321,20 +6321,15 @@ class FormValidatorsService {
6321
6321
  static DEFAULT_INPUT_TEXT = 'text';
6322
6322
  static DEFAULT_INPUT_TEXTAREA = 'textAreas';
6323
6323
  static addValidators(caseField, control) {
6324
- const isMandatory = caseField.display_context === Constants.MANDATORY &&
6325
- !FormValidatorsService.isCustomValidatedType(caseField);
6326
- const isOptionalText = caseField.display_context === 'OPTIONAL' && caseField.field_type.type === 'Text';
6327
- if (isMandatory || isOptionalText) {
6328
- const validators = [];
6329
- if (isMandatory) {
6330
- validators.push(Validators.required);
6331
- }
6324
+ if (caseField.display_context === Constants.MANDATORY &&
6325
+ !FormValidatorsService.isCustomValidatedType(caseField)) {
6326
+ const validators = [Validators.required];
6332
6327
  if (caseField.field_type.type === 'Text') {
6333
6328
  validators.push(this.markDownPatternValidator());
6334
6329
  if (caseField.field_type.regular_expression) {
6335
6330
  validators.push(Validators.pattern(caseField.field_type.regular_expression));
6336
6331
  }
6337
- else if (isMandatory) {
6332
+ else {
6338
6333
  validators.push(this.emptyValidator());
6339
6334
  }
6340
6335
  if (caseField.field_type.min && (typeof caseField.field_type.min === 'number')) {
@@ -6353,7 +6348,7 @@ class FormValidatorsService {
6353
6348
  }
6354
6349
  control.setValidators(validators);
6355
6350
  }
6356
- else if (caseField.display_context === 'OPTIONAL' && this.isTextAreaType(caseField.field_type.type)
6351
+ else if (caseField.display_context === 'OPTIONAL' && (caseField.field_type.type === 'Text' || this.isTextAreaType(caseField.field_type.type))
6357
6352
  || (caseField.display_context === 'COMPLEX' && caseField.field_type.type === 'Complex')) {
6358
6353
  control.setValidators(this.markDownPatternValidator());
6359
6354
  }