Skip to content

Bioroxx/ngx-better-forms

Repository files navigation

📋 ngx-better-forms

Better, cleaner, and more maintainable reactive form utilities for Angular.

status Build npm version License


🚀 Features

  • 🧩 Conditional validators for complex reactive forms
  • ⚡ Utility methods to simplify control management
  • 🧪 100% unit tested

📘 Documentation

https://bioroxx.github.io/ngx-better-forms

📦 Installation

npm install @ngx-better-forms/better-forms

💡 Example Usage

See short examples below.

You can find a full feature showcase in the documentation.

Conditional Validators

Add validators to a target FormControl, based on the current value of another FormControl.

formGroup = this.formBuilder.group(
  {
    field1: new FormControl<string>(''),
    target: new FormControl<string>(''),
  },
  {
    validators: [
      BetterValidation.conditionalValidators({
        targetControlPath: 'target',
        targetValidators: [Validators.required],
        conditions: [
          {
            controlPath: 'field1',
            testValues: ['a', 'b'],
          },
        ],
      }),
    ],
  },
);

Conditional Disable

formGroup = this.formBuilder.group(
  {
    field1: new FormControl<string>(''),
    target: new FormControl<string>(''),
  },
  {
    validators: [
      BetterDisable.conditionalDisable({
        targetControlPath: 'target',
        conditions: [
          {
            controlPath: 'field1',
            testValues: ['a', 'b'],
          },
        ],
      }),
    ],
  },
);

⚠️ Disclaimer:
This library is currently in very early development.
Features, APIs, and behavior may change without notice — use with caution, but be inspired. ✨

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published