Giter Site home page Giter Site logo

endykaufman / ngx-dynamic-form-builder Goto Github PK

View Code? Open in Web Editor NEW
116.0 4.0 28.0 29.19 MB

FormBuilder + class-transformer + class-validator = dynamic form group builder for Angular

Home Page: https://endykaufman.github.io/ngx-dynamic-form-builder

License: MIT License

HTML 23.33% TypeScript 64.66% JavaScript 10.87% Shell 0.26% SCSS 0.88%
form-builder class-transformer class-validator auto dynamic formgroup form validator validation object

ngx-dynamic-form-builder's Introduction

ngx-dynamic-form-builder

Build Status npm version monthly downloads

FormBuilder + class-transformer-global-storage + class-validator-multi-lang = dynamic form group builder for Angular

Installation

npm i --save class-transformer-global-storage class-validator-multi-lang ngx-dynamic-form-builder

BREAKING CHANGE !!!

Version above 2 has a completely rewritten code, partially backwards compatible

Now @Expose and @Exclude decorators are used to define model fields, the new version is rigidly dependent on class-transform

Dependencies are not used original, but forks with additional necessary properties, when using this library, you need to replace all original imports with forks with modifications

Fork class-validator-multi-lang - adds translation capability for errors (PR:typestack/class-validator#743)

Fork class-transformer-global-storage - adds the ability to get meta information about all used classes (PR:typestack/class-transformer#929)

For correct parse metadata, need remove compilerOptions.downlevelIteration and append compilerOptions.emitDecoratorMetadata: true in tsconfig.json

Links

Demo - Demo application with ngx-dynamic-form-builder.

Stackblitz - Simply sample of usage on https://stackblitz.com

Usage

company.ts

import { Validate, IsNotEmptym } from 'class-validator-multi-lang';
import { TextLengthMore15 } from '../utils/custom-validators';
import { marker } from '@ngneat/transloco-keys-manager/marker';
import { Expose, Type } from 'class-transformer-global-storage';

export class Company {
  @Expose()
  id: number;

  @Validate(TextLengthMore15, {
    message: marker('The company name must be longer than 15'),
  })
  @IsNotEmpty()
  @Expose()
  name: string;

  constructor(data?: any) {
    if (data === undefined) {
      data = {};
    }
    this.id = data.id;
    this.name = data.name;
  }
}

app.module.ts

import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { CompanyPanelComponent } from './company-panel.component';

@NgModule({
  imports: [
    ...
    FormsModule,
    ReactiveFormsModule,
    ...
  ],
  declarations: [
    ...
    CompanyPanelComponent,
    ...
  ],
  ...
})
export class AppModule {}

company-panel.component.html

<form [formGroup]="form" *ngIf="form?.customValidateErrors | async as errors" novalidate>
  <input formControlName="name" placeholder="Name" />
  <p *ngIf="errors.name?.length">Error: {{errors.name[0]}}</p>
  <p>Form status: {{ form.status | json }}</p>
  <p>Form class-validator-multi-lang errors: {{errors|json}}</p>
  <p *ngIf="savedItem">Saved item: {{savedItem|json}}</p>
  <button (click)="onLoadClick()">Load</button>
  <button (click)="onClearClick()">Clear</button>
  <button (click)="onSaveClick()" [disabled]="!form.valid">Save</button>
</form>

company-panel.component.ts

import { DynamicFormGroup, DynamicFormBuilder } from 'ngx-dynamic-form-builder';
import { Company } from './../../shared/models/company';
import { Input, Component } from '@angular/core';
import { Validators } from '@angular/forms';

@Component({
  selector: 'company-panel',
  templateUrl: './company-panel.component.html',
})
export class CompanyPanelComponent {
  form: DynamicFormGroup<Company>;

  @Input()
  item = new Company({
    id: 11,
    name: '123456789012345',
  });

  fb = new DynamicFormBuilder();

  savedItem?: Company;

  constructor() {
    this.form = this.fb.rootFormGroup(Company, {
      name: '',
    });
  }
  onLoadClick(): void {
    this.savedItem = undefined;
    this.form.object = this.item;
  }
  onClearClick(): void {
    this.savedItem = undefined;
    this.form.object = new Company();
  }
  onSaveClick(): void {
    if (this.form.valid) {
      this.savedItem = this.form.object;
    } else {
      this.savedItem = undefined;
    }
  }
}

custom-validators.ts

import { ValidatorConstraintInterface, ValidatorConstraint } from 'class-validator-multi-lang';

@ValidatorConstraint()
export class TextLengthMore15 implements ValidatorConstraintInterface {
  validate(text: string) {
    return text ? text.length > 15 : false;
  }
}

Support multi-language translate validation errors (I18n)

Because multi-language supported in class-validator-multi-lang, now ngx-dynamic-form-builder also support this feature

set validation messages as settings when create form group

this.form = this.fb.rootFormGroup(
  Company,
  {
    name: '',
  },
  {
    classValidatorOptions: {
      messages: {
        'The company name must be longer than 15': 'company name must be longer than 15 (translate on other language)',
      },
    },
  }
);

set validation messages on runtime after for exists form group

this.form.patchDynamicFormBuilderOptions({
  classValidatorOptions: {
    messages: {
      'The company name must be longer than 15': 'company name must be longer than 15 (translate on other language)',
    },
  },
});

set translate property name in error

this.form.patchDynamicFormBuilderOptions({
  classValidatorOptions: {
    titles: {
      regionNum: 'number of region (translate property name in error on other language)',
    },
  },
});

set validation messages and properties name global for all instance of form group in project

setGlobalDynamicFormBuilderOptions({
  classValidatorOptions: {
    messages: {
      'The company name must be longer than 15': 'company name must be longer than 15 (translate on other language)',
    },
    titles: {
      regionNum: 'number of region (translate property name in error on other language)',
    },
  },
});

Observable Errors

The customValidateErrors property can be subscribed for cases in which your code should act on changes in errors

company-panel.component.html

<form [formGroup]="form" *ngIf="form?.customValidateErrors | async as errors" novalidate>
  <input formControlName="name" placeholder="Name" />
  <p *ngIf="errors.name?.length">Error: {{errors.name[0]}}</p>
  <p>Form status: {{ form.status | json }}</p>
  <p>Observable validation errors: {{errors|json}}</p>
  <p *ngIf="savedItem">Saved item: {{savedItem|json}}</p>
  <button (click)="onLoadClick()">Load</button>
  <button (click)="onClearClick()">Clear</button>
  <button (click)="onSaveClick()" [disabled]="!form.valid">Save</button>
</form>

company-panel.component.ts

import { DynamicFormGroup, DynamicFormBuilder } from 'ngx-dynamic-form-builder';
import { Company } from './../../shared/models/company';
import { Input, Component } from '@angular/core';
import { Validators } from '@angular/forms';
import { Subscription } from 'rxjs';

@Component({
  selector: 'company-panel',
  templateUrl: './company-panel.component.html',
})
export class CompanyPanelComponent implements onDestroy {
  form: DynamicFormGroup<Company>;

  @Input()
  item = new Company({
    id: 11,
    name: '123456789012345',
  });

  @Input()
  strings = Company.strings;

  fb = new DynamicFormBuilder();

  savedItem?: Company;

  errorChangeSubscription: Subscription;

  constructor() {
    this.form = this.fb.rootFormGroup(Company, {
      name: '',
    });

    this.errorChangeSubscription = this.form.customValidateErrors.subscribe((allErrors) => {
      console.log(`Errors changed: ${allErrors}`);
    });
  }
  ngOnDestroy() {
    if (this.errorChangeSubscription != null && this.errorChangeSubscription.closed === false) {
      this.errorChangeSubscription.unsubscribe();
    }
  }
  onLoadClick(): void {
    this.savedItem = undefined;
    this.form.object = this.item;
    this.form.validateAllFormFields();
  }
  onClearClick(): void {
    this.savedItem = undefined;
    this.form.object = new Company();
    this.form.validateAllFormFields();
  }
  onSaveClick(): void {
    this.form.validateAllFormFields();
    if (this.form.valid) {
      this.savedItem = this.form.object;
    } else {
      this.savedItem = undefined;
    }
  }
}

License

MIT

ngx-dynamic-form-builder's People

Contributors

endykaufman avatar greenkeeper[bot] avatar scottmgerstl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ngx-dynamic-form-builder's Issues

@ValidateIf with @ValidateNested does not work in all cases

Sometimes when we use ValidateIf with ValidateNested and condition in ValidateIf is false form validity still reports as invalid, weven though there are no custom validation errors.

Here is stackblitz for this: https://stackblitz.com/edit/ngx-dynamic-form-builder-rym9yj?file=app%2Fshared%2Fmodels%2Fuser.ts

Repo steps:

  1. Click Load
  2. Clear department
  3. username is admin which is different then john in ValidateIf, therefore form status should be valid
  4. Observe Form status as "Invalid"

An in-range update of conventional-changelog-cli is breaking the build 🚨

The devDependency conventional-changelog-cli was updated from 2.0.5 to 2.0.7.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

conventional-changelog-cli is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @angular/cli is breaking the build 🚨

The devDependency @angular/cli was updated from 9.0.3 to 9.0.4.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@angular/cli is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v9.0.4

Commits

@angular/cli (9.0.4)

Commit Description Notes
expand locale pattern in all schemas for all cases
directly remove ansi color codes when no color support

@schematics/angular (9.0.4)

Commit Description Notes
Allow empty string in the type option

@angular-devkit/schematics-cli (0.900.4)

Commit Description Notes
provide resolvePaths to NodeWorkflow [Closes #17067]

@angular-devkit/build-angular (0.900.4)

Commit Description Notes
allow function in filename while changing the name of compiling chunks [Closes #17087]
limit the amount of CPUs used by workers
fix autoprefixer comments support in scss [Closes #17041]
baseHref with protocol and localize option
update core-js to 3.6.4 [Closes #16955]

@angular/pwa (0.900.4)

Commit Description Notes
use relative paths in webmanifest

@ngtools/webpack (9.0.4)

Commit Description Notes
don't elide decorated method parameter type reference [Closes #17080]
always use VE for deprecated string route discovery
handle union type with a nullable argument


Special Thanks

Alan Agius, Sachin Grover, Charles Lyding, Doug Parker, Cyrille Tuzi, Schneider

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @angular/cli is breaking the build 🚨

The devDependency @angular/cli was updated from 7.1.0 to 7.1.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@angular/cli is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v7.1.1

Commits

@ngtools/webpack (7.1.1)

Commit Description Notes
files are not being updated when using `allowJs` or `resolveJsonModule` (#13089) [Closes #13076]
[Closes #12964]
cleanup resources after modules are loaded (#12994)

@schematics/update (0.11.1)

Commit Description Notes
replace environment variables in npm/yarn rc

@schematics/angular (7.1.1)

Commit Description Notes
let tslint resolve codelyzer (#13101) [Closes #13101]
[Closes #13100]
add providers into providers metadata but not inner Object with ut. (#13081)

Special Thanks

Alan Agius, Charles Lyding, Vikram Subramanian, 赵正阳, Hans Larsen, Mathou54, Krishna Mohan

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of core-js is breaking the build 🚨

The dependency core-js was updated from 2.5.7 to 2.6.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

core-js is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for 2.6.0 - 2018.12.05
Commits

The new version differs by 11 commits.

  • f980318 2.6.0
  • f0b4154 add es6.regexp.exec as a direct dependency of _fix-re-wks for prevent breakage of existent code
  • a221e2a replace redefine by hide because of Chrome 38 bug with symbols conversion
  • 41e41e9 add some caps for the library version
  • 79db861 Merge pull request #458 from nicolo-ribaudo/backport-453
  • b0a70f9 Backport 41a8b12c8e641061e3576f89023f0a8fa903b81b
  • f77f88e Backport gh-453
  • 04b76e8 Merge pull request #435 from nicolo-ribaudo/backport-named-replace
  • 2b102b7 Polyfll named groups in RegExp#@@replace
  • fd64c48 Merge pull request #428 from nicolo-ribaudo/backport-es2015-regex
  • bc6ed09 Make RegExp#[Symbol.*] methods call exec

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

feat: support numbers, booleans in formarrays

I noticed this at L414

if (value && Object.keys(value).length > 0) { object[key].push(value); }

This is under getObject -> else if (this.controls[key] instanceof FormArray). The story here is that an object of class type TModel is created from the controls' values. Besides the fact that null values may be desired in the object's array, this simply ignores numbers as values i.e. I need to create an array of numbers in the object.

When .validate (L121) is called, it invokes this.object (L129) which, in turn, invokes getObject. The validation result will, therefore always return errors when a form array of primitive numbers is used when it is expected that it be populated, as per the validation decorators present.

fix: use value from getObject if parent is a group object

In setObjectValueAndGetValidationErrors(fieldName, control, validationOptions) at L882, the object is retrieved from the parent if the parent is DynamicFormGroup, but the value at fieldName in the retrieved object is immediately replaced at L900. This would go on to fail validation in a pesky manner if the class/factoryModel of the parent uses @Type or @Transform and the likes from class-transformer. For example, if the input from the UI gives a string, and the property to which it is bound in the factory model is expected to be transformed to a number before other validators can take effect, L900 would replace the transformed data and go on to fail with the call to getValidationErrors at L903. The error is rather hidden; I found it in the nativeValidateErrors BehaviorSubject (.value) as a customValidation error. Both formErrors and errors were null in this case.

I suggest the following to replace L893 to L902:
let object; if (control.parent instanceof DynamicFormGroup) { object = (control.parent as DynamicFormGroup<any>).object; } else if (control.parent) { object = control.parent.value; object[fieldName] = control.value; } else { object = {}; object[fieldName] = control.value; }

Webstorm not auto-completing class-validator

Webstorm IDE do not propose me to import the decorators I use from class-validator (and class transformer). Like @IsNotEmpty(), my IDE is acting like the package does not exist. But when adding the import manually he recognize it and compile.

It is maybe because ngx-dynamic-for-builder has its own version of class-validator.
Would it not make more sense to have class-validator and class-transformer as peer-dependencies only ?

I worked around the auto-import issue, by adding the class-validator and class-transformer as dependencies of my project.

An in-range update of @angular-devkit/build-angular is breaking the build 🚨

The devDependency @angular-devkit/build-angular was updated from 0.13.8 to 0.13.9.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@angular-devkit/build-angular is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Why does the example use @Input() decorators ?

What is the reason for having Input decorators:

  @Input()
  form: DynamicFormGroup<Company>;
  @Input()
  item = new Company({
    'id': 11,
    'name': '123456789012345'
  });

Are they necessary ? They do not seem to have any use in the example.

form has custom error message for a valid control?

I get a confusing situation when validating a formcontrol with @matches:

When using a regular expression as validation on a form field and put the 'g' modifier on it, then the form control still have customErrors (or formErrors) even if the control is valid. When I remove the 'g' modifier on the regular expression it works perfectly fine.

I adjusted your stackblitz-example to show the situation: https://stackblitz.com/edit/ngx-dynamic-form-builder-qn5zrb (type 'abc' in the input field. Then the form control is valid but the error message still appears)

I do not know if the 'g' modifier on the regular expression makes sense in that case. But in any case no valid form control should have error messages.

Bug: regionNum inconsistency between examples (group versus no group?)

In the demo, on the advanced tab and experimental tabs, the regionNum has the following configuration:

@IsOptional()
@Min(1)
@Max(99)
regionNum: number;

In the Advanced example, if you type in a number greater than 99 or less than 1, you get an error.

In the Experimental example, not matter what value is provided, there is no error

An in-range update of prettier is breaking the build 🚨

The devDependency prettier was updated from 1.17.1 to 1.18.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

prettier is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for 1.18.0

🔗 Release Notes

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @types/node is breaking the build 🚨

The devDependency @types/node was updated from 13.7.0 to 13.7.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@types/node is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Wrong form generated when providing only first argument to dynamic form builder

export class Post {
  @IsArray()
  @IsOptional()
  readonly tagsId: number[] = [];

  constructor(post?: Partial<Post>) {
    super();

    plainToClassFromExist(this, post);
  }
}
      this.form1= this.fb.group<Post>(Post);
      console.log(this.form.get('tagsId').value); // [{}]

      this.form2= this.fb.group<Post>(Post, new Post());
      console.log(this.form.get('tagsId').value); // []

It would be expected that both return an empty array. But when providing only the first argument it return an array of size 1, containing an empty object.

An in-range update of conventional-recommended-bump is breaking the build 🚨

The devDependency conventional-recommended-bump was updated from 4.0.1 to 4.0.3.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

conventional-recommended-bump is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Feature Proposal: Add validation definitions to FormControls

Proposal to add the class-validator metadata to the form controls it is applied to allowing the validation rules that are applied to the form control to be inspected at any point during runtime. Currently, in Angular, during runtime, only invalid rules are available at any given runtime

I have opened PR #84 which is intended to be reviewed and merged after PR #81 (code refactor: organization and documentation).

You can see the feature specific code changes in this comparison between my branches: ScottMGerstl/ngx-dynamic-form-builder@refactor/organization-n-documentation...ScottMGerstl:feature/validation-on-controls

An in-range update of @angular-devkit/build-angular is breaking the build 🚨

The devDependency @angular-devkit/build-angular was updated from 0.8.3 to 0.8.4.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@angular-devkit/build-angular is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Array validation ({each:true})

Hi there,
I was getting some weird behavior, did some debugging, and found out my installed dynamic form builder does not support array-mode of validators (by setting options.each = true).

Was going to make a pull request but then realized your implementation has changed drastically since the version that I'm still using (1.3.5). (Stuck because recent class-validator does not offer global i18n.)

So possibly this issue is already resolved in newest version.
Just to be sure and help if it is not, I thought I'd just let you know about the needed code change.

In createDynamicValidate, replace

const isValid = control.parent && control.parent.value
	? validator.validateValueByMetadata(control.value, validationMetadata)
	: true;

by

let isValid = true;
function convertToArray(val) {
	if (val instanceof Map) {
		return Array.from(val.values());
	}
	return Array.isArray(val) ? val : Array.from(val);
}

if (control.parent && control.parent.value) {
	const value = control.value;
	if (validationMetadata.each) {
		if (value instanceof Array || value instanceof Set || value instanceof Map) {
			var arrayValue = convertToArray(value);
			isValid = arrayValue.every(function (subValue) { 
				return validator.validateValueByMetadata(subValue, validationMetadata); 
			});
		}
	}
	else {
		isValid = validator.validateValueByMetadata(value, validationMetadata);
	}
}

which reimplements the code used in ValidationExecutor.defaultValidations.

If this is outdated due to different implementation feel free to close.

Edit: Example

ExampleClass {
	@IsString()
	prop1:string

	@IsString({each:true})
	list:string[];
}

Without this change, dto.list would not validate correctly, while prop1 does.
The change shown above adds the code responsible for iterating over Array from class-validator.

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml
  • The new Node.js version is in-range for the engines in 1 of your package.json files, so that was left alone

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

feat: support arrays with multiple types

onlyFields at L316, which contains the issue #160 , assumes that all elements of a form array must be of the same type. This would ignore the fields of one of the types in (number | MyClass)[], for example.

Cannot find module 'ngx-dynamic-form-builder'

We cloned project

npm install
ng serve demo
and got errors as "Cannot find module 'ngx-dynamic-form-builder'." where ever present below import line -

import { DynamicFormBuilder, DynamicFormGroup } from 'ngx-dynamic-form-builder'

An in-range update of angular2 is breaking the build 🚨

There have been updates to the angular2 monorepo:

  • The dependency @angular/cdk was updated from 7.1.0 to 7.1.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the angular2 group definition.

angular2 is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for fondant-friendship

Bug Fixes

  • a11y: don't handle disallowed modifier keys in typeahead mode (#14301) (700f20f), closes #14274
  • badge: badge instances not being cleaned up on destroy (#14265) (da3776f)
  • checkbox: poor color contrast for disabled checkbox (#14044) (9c86b5f)
  • chips: invert focus overlay on dark theme (#14204) (7af8d02)
  • drag-drop: add support for dragging svg elements in IE11 (#14215) (81db16c), closes #14214
  • drag-drop: dragged elements blurry in some browsers (#14299) (63174d2), closes #14283
  • drag-drop: only add top-level drop lists to drop group (#14130) (4acecd7)
  • drag-drop: remove expensive style recalculation (#14189) (f212345)
  • form-field: error when native select has no options (#14102) (0ef75ea), closes #14101
  • list: don't handle events when modifier key is pressed (#14313) (0c7ce7a)
  • menu: allow alternate roles to be set on menu item (#14165) (3f1588f), closes #14163
  • ng-add: do not throw if custom builder is used for "test" (#14203) (498a3d8), closes #14176
  • scrolling: default to vertical CSS class for invalid orientation (#14145) (dbe27c4)
  • scrolling: provide virtual scroll viewport as scrollable (#14168) (c552504)
  • slide-toggle: label not being read out by JAWS (#14304) (754414b), closes #4610
  • slide-toggle: label not being read out by screen reader on IE (#14259) (5264804)
  • stepper: showing hover state after tap on touch devices (#14074) (f3031ad)
  • tabs: avoid hitting change detection if text content hasn't changed (#14251) (9778af2), closes #14249
  • tabs: blurry text in scrolled header on some browsers (#14303) (f7c8026)
FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

lodash-es usage reasons, unexpected token export

What is the reason for using lodash-es in the project? Its crashed my build of the Angular universal project with next error:

.../node_modules/lodash-es/lodash.js:10
export { default as add } from './add.js';
^^^^^^

SyntaxError: Unexpected token export

part of my package json

"@angular/cdk": "^7.1.0",
"@angular/common": "7.1.1",
"@angular/compiler": "7.1.1",
"@angular/core": "7.1.1",
"ngx-dynamic-form-builder": "^0.4.0" 

As temporary solution I do

rm -rf ./node_modules/lodash-es && cp -r ./node_modules/lodash ./node_modules/lodash-es

before every ng build --prod running; but I want to resolve this problem more correctly.

v2: "Greedy" creation of nested Models causes recursive errors and unexpected creation of submodels

Issue description

Edit: Added more thorough information on the issue.

v2 introduces a different submodel handling.
Its behaviour is "greedy" now.

Example:

		class Company {
			@Expose()
			name: string;
			@Expose()
			@Type(()=>User)
			manager:User;
		}
	
		class User {
			@Expose()
			name: string;
	
			@Type(type => Company, {})
			@Expose()
			optCompany?: Company = undefined;
		}

The above sample will

  • crash with call stack error because getMetadata() will recursively loop between User.optCompany and Company.manager
  • if recursiveness is limited, It would still assign a new Company model to optCompany, even though class-transformer would default it to undefined

This was not the case with DFB v1.

I checked the getMetadata function but could not find anything hinting to an existing mechanism to prevent this behavior.

Solutions

a) specify a max. depth for submodel creation. If a model has multiple submodels, it might become difficult to use this method as it lacks precise configuration Not a solid solution, but can at least prevent app freezes / call stack exceeded errors.

b) detect if a model circularly references itself and abort creation in that case. Insufficient solution because it's unconfigurable, it would only help to prevent some bad errors.

c) pass contextual information on which submodels should be created greedily and which models are optional.
In addition to that, this must also work for sub-submodels and possibly there is even need to distinguish between if the model is being created as a first-level-submodel or a 1+n-level-submodel.

Next

I really need to fix this as fast as possible, so I'm currently working on implementing it.
a) makes sense for preventing recursiveness,
but only
c) would really be able to provide a solution to the issue.

set updateOn: blur while form building

Hi there, using FormGroup we can configure updateOn parameter to each form control, but I can't find a way to set this param using DynamicFormBuilder.

Bug: Inconsistent behavior for error descriptions.

In the following sections of the demo, error messages do not appear under the fields or in the area for all errors until some value on the form changes:

  • Simple
  • Advanced
  • Experimental: User Panel

In these other sections of the demo, all invalid fields are marked immediately invalid and have all errors available on the UI

  • Experimental: login panel
  • Form Array and Steps (all fields and steps)

Please update dependency class-validator

class-validator finally introduced tree-shakable validators (since 0.12.0, see Pull 568).

This makes it a lot more compact to use and stops requiring hacks to exclude bold dependencies (libphonenumber, hundreds of KB).
Would you mind to push the version used by dynamic form builder? Thank you :)

Note: I just read about a breaking change which might require changes:
"all validations (except system ones) are type ValidationTypes.CUSTOM_VALIDATION now - mostly internal change"

If I do remember the source of dynamic form builder correctly, it distinguishes between several types.

Typo issue in example

  this.errorChangeSubscription = this.form.customValidateErrors.subscribe((allErrors) => {
      console.log('Errors changed': allErrors);
    })

This won't compile, did you mean to write :

 console.log(`Errors changed: ${allErrors}`);

An in-range update of ng-packagr is breaking the build 🚨

The devDependency ng-packagr was updated from 4.4.0 to 4.4.5.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

ng-packagr is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

How to add multiple fields validators ?

With a normal form build you would do that bellow:

this.myForm = fb.group({
  field1: [null],
  field2: [null]
  // more fields 
}, {validator: this.myValidator})
myValidator(group: FormGroup) {
  let sum = 0;
  for(let a in group.controls) {
    sum += group.get([a]).value;
  }
  return sum > 10 ? { notValid: true} : null
}

Signature of function group of DynamicFormBuilder is:

group<TModel>(factoryModel: ClassType<TModel>, controlsConfig?: FormModel<TModel> | DynamicFormGroupConfig, extra?: DynamicFormGroupConfig): DynamicFormGroup<TModel>;

when signature of group function of FormBuilder is:

group(controlsConfig: {
        [key: string]: any;
    }, options?: AbstractControlOptions | {
        [key: string]: any;
    } | null): FormGroup;

@see https://stackoverflow.com/questions/48704858/angular-5-validate-multiple-input-fields-by-sum-up-values

Update to latest class-validator

This package does not seem to work with the latest version of class-validator. Would be cool to get it updated to benefit of a lot of cool new validations.

⚠️ Greenkeeper is no longer available for new installations

Hello!

Greenkeeper is no longer available for new installations.

The service will be saying goodbye 👋 and passing the torch to Snyk on June 3rd, 2020. Find out more at greenkeeper.io.

If this is your only Greenkeeper installation, you can just sign up for Snyk directly, it’s free for Open Source and even has free features for private projects as well.

Nevertheless, thanks for your interest in Greenkeeper! We’re sure your repositories will find a good home at Snyk ☀️🏡💜

All the best from everyone at Greenkeeper! 👋🤖🌴

Update to Angular v13

Hey, just wanted to know if there is a plan to update to Angular 13? There are some packages like class-validator not building on Angular 13 since this project requires angular 11.0.9.

An in-range update of karma is breaking the build 🚨

The devDependency karma was updated from 3.1.1 to 3.1.2.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

karma is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v3.1.2

Bug Fixes

Features

Commits

The new version differs by 11 commits.

  • 7d4d347 chore: release v3.1.2
  • 5077c18 chore: update contributors
  • fb05fb1 fix(server): use flatted for json.stringify (#3220)
  • 2682bff feat(docs): callout the key debug strategies. (#3219)
  • 4e87902 fix(changelog): remove release which does not exist (#3214)
  • 30ff73b fix(browser): report errors to console during singleRun=false (#3209)
  • 5334d1a fix(file-list): do not preprocess up-to-date files (#3196)
  • dc5f5de fix(deps): upgrade sinon-chai 2.x -> 3.x (#3207)
  • d38f344 fix(package): bump lodash version (#3203)
  • ffb41f9 refactor(browser): log state transitions in debug (#3202)
  • 240209f fix(dep): Bump useragent to fix HeadlessChrome version (#3201)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

feat: support empty form array

I noticed on L322 that the else clause assumes the form array must contain at least one element. Similar to #159, empty arrays should be supported. Currently, form-building with an empty form array i.e. this.dfb.array([]) fails. I suggest wrapping L317 to L325 in if ((fields[key] as FormArray).controls[0] != undefined) {

An in-range update of @types/node is breaking the build 🚨

The devDependency @types/node was updated from 10.12.10 to 10.12.11.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@types/node is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Feature proposal: Create a non-observable API for errors

Angular's change detection can handle the changes in the form errors without the use of an observable. I would like to propose introducing formErrors: ShortValidationErrors to the dynamic-form-group that is read into at the same point that the observable's next function is called.

A user will then be able to access the errors in the view or code through form.formErrors instead of (form.customValidateErrors | async) or await this.form.customValidateErrors.toPromise(); (or any other observable handling strategies).

I have opened PR #82 which is intended to be reviewed and merged after PR #81 (code refactor: organization and documentation).

You can see the feature specific code changes in this comparison between my branches: ScottMGerstl/ngx-dynamic-form-builder@refactor/organization-n-documentation...ScottMGerstl:feature/sync-form-errors

Refactor proposal: Code organization and cleanup prior to feature PRs

Co-workers and I have a need to access all the applied validation on form controls at the point they are created (currently, only the invalid validators can be dynamically retrieved at this point) for dynamic UI purposes.

We would also appreciate a simplified API for for errors.

In preparation for writing these features, while reading through the code, I organized it and documented it to help me pick out what the code is doing at a glance.

I have submitted PR #80 with this refactor in case you would like to take advantage of the organization.

I understand that I may have a different style of coding than you and would be happy to make any changes based on your style guide. I tried to keep as much of your style while helping with readability for my co-workers and I.

If you choose not to accept this PR, we will maintain our own fork.

I have noted the changes with comments on the PR as the re-organization may make it difficult to track.

TESTING
I have tested for parody with your most current online demo and have found that everything works the same except the Task description on FormArray and Steps.

  • In your hosted example, the description is marked immediately invalid when a new description is added and is empty.
  • In my code, it will not mark it immediately invalid but, if you put a value in and then remove it, it is marked as invalid. If you could direct me to which function is responsible for this, I can further debug and fix the issue.

An in-range update of lodash-es is breaking the build 🚨

The dependency lodash-es was updated from 4.17.12 to 4.17.13.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

lodash-es is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.