VeryGoodOpenSource / formz

Licence: MIT license
A unified form representation in Dart used at Very Good Ventures 🦄

Programming Languages

dart
5743 projects
C++
36643 projects - #6 most used programming language
CMake
9771 projects
HTML
75241 projects
c
50402 projects - #5 most used programming language
swift
15916 projects

Projects that are alternatives of or similar to formz

Redux Form
A Higher Order Component using react-redux to keep form state in a Redux store
Stars: ✭ 12,597 (+4708.02%)
Mutual labels:  forms, form-validation
Vue Dynamic Forms
Easy way to dynamically create reactive forms in vue based on a varying business object model
Stars: ✭ 146 (-44.27%)
Mutual labels:  forms, form-validation
Form For
ReactJS forms made easy
Stars: ✭ 118 (-54.96%)
Mutual labels:  forms, form-validation
Jafar
🌟!(Just another form application renderer)
Stars: ✭ 107 (-59.16%)
Mutual labels:  forms, form-validation
Form bloc
🔥 Dart and Flutter Package 🔥 Easy Form State Management using BLoC pattern 🔥 Wizard/stepper forms, asynchronous validation, dynamic and conditional fields, submission progress, serialization and more! 🔥
Stars: ✭ 239 (-8.78%)
Mutual labels:  forms, form-validation
React Forms
React library for rendering forms.
Stars: ✭ 111 (-57.63%)
Mutual labels:  forms, form-validation
Modal progress hud
A simple modal progress HUD (heads-up display, or progress indicator) for flutter
Stars: ✭ 137 (-47.71%)
Mutual labels:  forms, form-validation
Formidable
PHP 7 form library for handling user input
Stars: ✭ 27 (-89.69%)
Mutual labels:  forms, form-validation
Documentation
📋 Official documentation/website
Stars: ✭ 202 (-22.9%)
Mutual labels:  forms, form-validation
Formiz
🐜 React forms with ease! Composable, headless & with built-in multi steps
Stars: ✭ 159 (-39.31%)
Mutual labels:  forms, form-validation
Rsformview
A Cocoapods library designed to easily create forms with multiple data entry fields
Stars: ✭ 84 (-67.94%)
Mutual labels:  forms, form-validation
Final Form
🏁 Framework agnostic, high performance, subscription-based form state management
Stars: ✭ 2,787 (+963.74%)
Mutual labels:  forms, form-validation
Use Form
Build great forms without effort. 🚀
Stars: ✭ 42 (-83.97%)
Mutual labels:  forms, form-validation
Validate
A lightweight form validation script.
Stars: ✭ 227 (-13.36%)
Mutual labels:  forms, form-validation
Usetheform
React library for composing declarative forms, manage their state, handling their validation and much more.
Stars: ✭ 40 (-84.73%)
Mutual labels:  forms, form-validation
React Controlled Form
Flexible, Modular & Controlled Forms for React and Redux
Stars: ✭ 121 (-53.82%)
Mutual labels:  forms, form-validation
Flutter form builder
Simple form maker for Flutter Framework
Stars: ✭ 715 (+172.9%)
Mutual labels:  forms, form-validation
React Final Form
🏁 High performance subscription-based form state management for React
Stars: ✭ 6,781 (+2488.17%)
Mutual labels:  forms, form-validation
Ionic Forms And Validations
📝 Ionic Tutorial - Learn to use Forms and Validations in Ionic Angular apps. Get a FREE Ionic 5 Forms Starter App and learn to handle simple and custom validations. Includes complete ionic forms tutorial!
Stars: ✭ 155 (-40.84%)
Mutual labels:  forms, form-validation
Composable Form
Build type-safe composable forms in Elm
Stars: ✭ 179 (-31.68%)
Mutual labels:  forms, form-validation

📝 Formz

Very Good Ventures Very Good Ventures

Developed with 💙 by Very Good Ventures 🦄

ci coverage pub package License: MIT style: very good analysis


A unified form representation in Dart. Formz aims to simplify form representation and validation in a generic way.

Create a FormzInput

import 'package:formz/formz.dart';

// Define input validation errors
enum NameInputError { empty }

// Extend FormzInput and provide the input type and error type.
class NameInput extends FormzInput<String, NameInputError> {
  // Call super.pure to represent an unmodified form input.
  const NameInput.pure() : super.pure('');

  // Call super.dirty to represent a modified form input.
  const NameInput.dirty({String value = ''}) : super.dirty(value);

  // Override validator to handle validating a given input value.
  @override
  NameInputError? validator(String value) {
    return value.isEmpty ? NameInputError.empty : null;
  }
}

Interact with a FormzInput

const name = NameInput.pure();
print(name.value); // ''
print(name.isValid); // false
print(name.error); // NameInputError.empty
print(name.displayError); // null

const joe = NameInput.dirty(value: 'joe');
print(joe.value); // 'joe'
print(joe.isValid); // true
print(joe.error); // null
print(name.displayError); // null

Validate Multiple FormzInput Items

const validInputs = <FormzInput>[
  NameInput.dirty(value: 'jan'),
  NameInput.dirty(value: 'jen'),
  NameInput.dirty(value: 'joe'),
];

print(Formz.validate(validInputs)); // true

const invalidInputs = <FormzInput>[
  NameInput.dirty(),
  NameInput.dirty(),
  NameInput.dirty(),
];

print(Formz.validate(invalidInputs)); // false

Automatic Validation

class LoginForm with FormzMixin {
  LoginForm({
    this.username = const Username.pure(),
    this.password = const Password.pure(),
  });

  final Username username;
  final Password password;

  @override
  List<FormzInput> get inputs => [username, password];
}

void main() {
  print(LoginForm().isValid); // false
}

Caching validation results

For cases where the validator method has an expensive implementation, consider using the FormzInputErrorCacheMixin mixin to cache the error result and improve performance.

import 'package:formz/formz.dart';

enum EmailValidationError { invalid }

class Email extends FormzInput<String, EmailValidationError>
    with FormzInputErrorCacheMixin {
  Email.pure([super.value = '']) : super.pure();

  Email.dirty([super.value = '']) : super.dirty();

  static final _emailRegExp = RegExp(
    r'^[a-zA-Z\d.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z\d-]+(?:\.[a-zA-Z\d-]+)*$',
  );

  @override
  EmailValidationError? validator(String value) {
    return _emailRegExp.hasMatch(value) ? null : EmailValidationError.invalid;
  }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].