Philosophy
Formulaik aims to simplify form building across various front-end frameworks. Formulaik is not a form library itself, it defines a protocol for defining form inputs as a sole source of truth (data type, behaviour, validation) in json. That definition can be interpreted by any formulaik engine on any compatible front-end framework. Any input declares the component type it needs to collect the user's input. Any Formulaik engine renders the said input by requesting the component from libraries (components) and renders them with a standardized api.
Principles​
Convention over configuration​
Convention over configuration (also known as coding by convention) is a software design paradigm used by software frameworks that attempts to decrease the number of decisions that a developer using the framework is required to make without necessarily losing flexibility and don't repeat yourself (DRY) principles.Wikipedia
Break the Form into Small Reusable Components​
One of the fundamental principles of React is the concept of componentization. Apply this principle to your forms by breaking them down into small, reusable components. Each component should encapsulate a specific piece of the form’s functionality. This approach makes your code more modular and easier to maintain, and when combined with TypeScript, it enables strong type checking for each component. Read more
Standardize Input Interfaces: “value” and “onChange”​
To ensure consistency and compatibility, follow the standard input interface of providing “value” and “onChange” handlers for your form inputs. This approach allows React Hook Form to seamlessly integrate with your components while providing TypeScript with the necessary information to perform type checking. Read more
Don't repeat yourself (DRY)​
"Don't repeat yourself" (DRY) is a principle of software development aimed at reducing repetition of information which is likely to change, replacing it with abstractions that are less likely to change, or using data normalization which avoids redundancy in the first place.Wikipedia
Extreme refactoring​
Refactor mercilesslyFormulaik takes refactoring to the extreme by decluttering the app from the underlying features that different models use into a single package called feature. Contrarily to a middleware or an extension, a feature is a high level, conventioned, Predictable and versioned piece of code that provides a functional feature. Extreme refactoring with features yield extreme reusability from the ground-up by instilling a feature driven culture in your teams.
Variable → Function → Class → Module → Extension → Feature
Extreme refactoring
Functional programming​
(over object programming)
Functional programming is a paradigm of building computer programs using expressions and functions without mutating state and data. By respecting these restrictions, functional programming aims to write code that is clearer to understand and more bug resistant.Other influences​
- Code That Fits in Your Head book by Mark Seemann
- Formik
Should you use Formulaik?​
Formulaik is likely a good fit for you if:
- You want to quickly build a form for your project
- You want to reuse an input over different forms without copying it over and over
- You want to have clean, concise, readable and maintainable forms across your apps