Commit 0307ece2 authored by Merzough Münker's avatar Merzough Münker
Browse files

feat(RxapFormBuilder): save if the current control has an required validator

parent 12b9385a
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
# Changelog

## [0.7.0]
### Added
- (RxapFormBuilder): save if the current control has an required validator

## [0.6.0]
### Added
- (schematics): add support for edit submit handlers
+1 −1
Original line number Diff line number Diff line
{
  "name": "@rxap/forms",
  "version": "0.6.0",
  "version": "0.7.0",
  "private": false,
  "author": "Merzough Münker",
  "homepage": "https://gitlab.com/rxap/packages",
+8 −1
Original line number Diff line number Diff line
@@ -15,7 +15,8 @@ import { MetadataKeys } from './decorators/metadata-keys';
import {
  AbstractControl,
  ValidatorFn,
  AsyncValidatorFn
  AsyncValidatorFn,
  Validators
} from '@angular/forms';
import {
  RxapAbstractControlOptions,
@@ -331,6 +332,12 @@ export class RxapFormBuilder<Form extends FormDefinition = FormDefinition> {
      this.coerceToFnArray<SetValueFn>(form, this.controlSetValue.get(controlId))
          .forEach(setValueFn => control.registerOnSetValue(setValueFn));

      if (Array.isArray(options.validators)) {
        if (options.validators.includes(Validators.required) || options.validators.includes(Validators.requiredTrue)) {
          Reflect.set(control, 'hasRequiredValidator', true);
        }
      }

      // set the form control instance to the form definition instance
      Reflect.set(form, controlId, control);