The Vue form assembly tool that won't break your heart 💔

Overview

Loveform

The Vue form assembly tool that won't break your heart 💔

NPM - Version Linters

Loveform is a tool that helps you build validated forms in Vue 3 without the need to handle the whole validation process yourself. This means that you no longer need to write a submit function with a huge if - else if - else chain of conditionals and a whole bunch of error variables. Just import the component you need to use, write a validation function and voilà! Your form is production ready!

Why Loveform?

When building forms, you can choose between using no library at all, using one of the libraries that include form validation handling as a secondary feature (like Vuetify) or using Loveform.

If you decide to use no library at all, you will soon find yourself with a ton of variables holding errors for different inputs, large validations that include tons of if statements and a huge template to tie it all together. Soon enough, you will start writing your own form assembly solution (just as I did), wasting valuable time that could be better used writing code that will actually improve your business/project.

If you decide to use a library that includes form validation handling as a secondary feature (like Vuetify), you will probably have a Very hard time customizing how your forms look like. These libraries almost always include default styling and other features that you probably don't want nor need.

If you decide to use Loveform, you will have the power to write fully validatable forms without having to worry about the validation chain, while being able to fully style your components however you desire 😈 .

The complete documentation is available on the official website.

Installation

Install using npm! (or your favourite package manager)

# Using npm
npm install loveform

# Using yarn
yarn add loveform

Please note that Loveform will only work with Vue 3.

Basic Usage

The basic principle is simple: write a form as you would write an ordinary form with no validations, add some validations to the fields you want to validate and then forget about validations and focus on the rest of your application. Here's an example of an (unstyled) validated form:

<script setup lang="ts">
import { ref } from 'vue';
import axios from 'axios';
import { LForm, LInput } from 'loveform';

const email = ref('');
const password = ref('');

const emailValidations = [
  (content: string) => !!content.trim() || 'The \'email\' field is required',
  (content: string) => content.includes('@') || 'Invalid email',
];
const passwordValidations = [
  (content: string) => content.length >= 6 || 'The password needs at least 6 characters',
  (content: string) => !content.includes('&') || 'The password can\'t include the \'&\' character',
];

const submit = async () => {
  // This will only run if the validations pass
  await axios.post('https://backend.you/signup', {
    email: email.value,
    password: password.value,
  });
};
</script>

<template>
  <LForm @submit="submit">
    <LInput
      v-model="email"
      :validations="emailValidations"
    />
    <LInput
      v-model="password"
      :validations="passwordValidations"
    />
    <button type="submit">Submit!</button>
  </LForm>
</template>

Each validation corresponds to a function that receives the value in the input and returns true (if the value of the input is correct) or an error string. Each validation will be run sequentially from the first validation of the array to the last one, and the first validation to fail will be displayed as the error.

Available Components

The available components are listed below:

  • LForm: The form wrapper that validates inputs when trying to submit.
  • LInput: A validatable input component.
  • LTextarea: A validatable textarea component.
  • LCheckbox: A checkbox type input component that plays nicely with the LCheckboxGroup component.
  • LCheckboxGroup: A validatable group of LCheckbox components.

Development

Testing locally

To test locally, first link the library:

npm link

Then cd into the dev folder and copy the LPlayground.template.vue into a LPlayground.vue file:

cd dev
cp src/LPlayground.template.vue src/LPlayground.vue

Now, edit the LPlayground.vue file risk free to try the components you're working on:

nano src/LPlayground.vue  # or your favorite editor

Finally, run npm install and start the playground server!

npm install
npm run dev

You can see the development server running at http://localhost:3000.

Resources

Comments
  • How to add style to error message?

    How to add style to error message?

    How can I style the rendered error message by targeting it? It just renders in a

    tag without any class or ID, then how can we target it to apply style?

    opened by atif0075 1
  • Release 0.3.1

    Release 0.3.1

    Version 0.3.1 🎉

    Additions ➕

    • LForm components now include the l-form class to target the component using css.
    • LInput components now include the l-input class to target the component using css and a l-input__error class to target the component error using css.
    • LTextarea components now include the l-textarea class to target the component using css and a l-textarea__error class to target the component error using css.
    • LCheckbox components now include the l-checkbox class to target the component using css.
    • LCheckboxGroup components now include the l-checkbox-group__error class to target the component error using css.
    opened by daleal 0
  • Add styling capabilities

    Add styling capabilities

    Description

    This Pull Request adds the capability to target the elements using css by adding defined classes to each component and its error.

    Closes #16

    Requirements

    None.

    Additional changes

    None.

    opened by daleal 0
  • Release 0.3.0

    Release 0.3.0

    Version 0.3.0 🎉

    Additions ➕

    • There is now a LCheckbox component for checkboxes
    • There is now a LCheckboxGroup component to group and validate LCheckbox components

    Changes ➖

    • Now the validation composable is decoupled from the component's model
    opened by daleal 0
  • Update readme

    Update readme

    Description

    Add the available components as a list in the README.md file.

    Requirements

    None.

    Additional changes

    Update some fields in the package.json file.

    opened by daleal 0
  • Include grouped checkbox validation

    Include grouped checkbox validation

    Description

    Now there are new components: LCheckbox and LCheckboxGroup. These components can be used to validate checkboxes, by passing the validations to the LCheckboxGroup component and nesting the LCheckbox components inside itself.

    Requirements

    None.

    Additional changes

    None.

    opened by daleal 0
  • Refactor validations

    Refactor validations

    Description

    The validation composable was tightly coupled with the components using it via the v-model attribute. Now the value to be validated gets passed as a Ref<T> when initializing the validation composable.

    Requirements

    None.

    Additional changes

    None.

    opened by daleal 0
  • Release 0.2.0

    Release 0.2.0

    Version 0.2.0 🎉

    Additions ➕

    • Now the LForm component also has the hide-errors prop
    • There is now a LTextarea component

    Fixes 🐛

    • Now the attrs get passed correctly to the components
    opened by daleal 0
  • Update documentation

    Update documentation

    Description

    Update the README.md file to contain only a basic example and some links to the official documentation.

    Requirements

    None.

    Additional changes

    Changed the playground component's name to a more appropriate one.

    opened by daleal 0
  • Add a `hide-errors` prop to the `LForm` component

    Add a `hide-errors` prop to the `LForm` component

    Description

    Until now, errors could be hidden individually on each input component, but not as a whole for a specific form. Now there is a hide-errors prop for inputs and forms that hides the errors shown.

    Requirements

    None.

    Additional changes

    None.

    opened by daleal 0
  • Release 0.1.0

    Release 0.1.0

    Version 0.1.0 🎉

    Additions ➕

    • Validate the form before its native submission

    Breaking Changes ❌

    • The form now needs a @submit event to be passed to it in order to use the native submission

    Fixes 🐛

    • Bump up some subdependecies for security concerns
    opened by daleal 0
Releases(0.3.1)
  • 0.3.1(Jul 9, 2022)

    Version 0.3.1 🎉

    Additions ➕

    • LForm components now include the l-form class to target the component using css.
    • LInput components now include the l-input class to target the component using css and a l-input__error class to target the component error using css.
    • LTextarea components now include the l-textarea class to target the component using css and a l-textarea__error class to target the component error using css.
    • LCheckbox components now include the l-checkbox class to target the component using css.
    • LCheckboxGroup components now include the l-checkbox-group__error class to target the component error using css.
    Source code(tar.gz)
    Source code(zip)
  • 0.3.0(Apr 27, 2022)

    Version 0.3.0 🎉

    Additions ➕

    • There is now a LCheckbox component for checkboxes
    • There is now a LCheckboxGroup component to group and validate LCheckbox components

    Changes ➖

    • Now the validation composable is decoupled from the component's model
    Source code(tar.gz)
    Source code(zip)
  • 0.2.0(Apr 25, 2022)

    Version 0.2.0 🎉

    Additions ➕

    • Now the LForm component also has the hide-errors prop
    • There is now a LTextarea component

    Fixes 🐛

    • Now the attrs get passed correctly to the components
    Source code(tar.gz)
    Source code(zip)
  • 0.1.2(Apr 22, 2022)

  • 0.1.1(Apr 22, 2022)

  • 0.1.0(Apr 21, 2022)

    Version 0.1.0 🎉

    Additions ➕

    • Validate the form before its native submission

    Breaking Changes ❌

    • The form now needs a @submit event to be passed to it in order to use the native submission

    Fixes 🐛

    • Bump up some subdependecies for security concerns
    Source code(tar.gz)
    Source code(zip)
Owner
Daniel Leal
Software Engineer and Computer Science Student
Daniel Leal
Vue-input-validator - 🛡️ Highly extensible & customizable input validator for Vue 2

??️ Vue-input-validator demo! What is this package all about? By using this package, you can create input validators only with the help of a single di

null 14 May 26, 2022
The best @jquery plugin to validate form fields. Designed to use with Bootstrap + Zurb Foundation + Pure + SemanticUI + UIKit + Your own frameworks.

FormValidation - Download http://formvalidation.io - The best jQuery plugin to validate form fields, designed to use with: Bootstrap Foundation Pure S

FormValidation 2.8k Mar 29, 2021
Lightweight JavaScript form validation library inspired by CodeIgniter.

validate.js validate.js is a lightweight JavaScript form validation library inspired by CodeIgniter. Features Validate form fields from over a dozen r

Rick Harrison 2.6k Dec 15, 2022
Cross Browser HTML5 Form Validation.

Validatr Cross Browser HTML5 Form Validation. Getting Started View the documentation to learn how to use Validatr. Changelog Version 0.5.1 - 2013-03-1

Jay Morrow 279 Nov 1, 2022
jQuery form validation plugin

jQuery.validationEngine v3.1.0 Looking for official contributors This project has now been going on for more than 7 years, right now I only maintain t

Cedric Dugas 2.6k Dec 23, 2022
Simple and basic javascript form validations

JavaScript-Form-Validations Simple and basic javascript form validations Table of Validations: S. No. Type of validation Link 1 Non-empty text field h

MAINAK CHAUDHURI 23 Dec 17, 2022
Lightweight and powerfull library for declarative form validation

Formurai is a lightweight and powerfull library for declarative form validation Features Setup Usage Options Methods Rules Examples Roadmap Features ?

Illia 49 May 13, 2022
This is Example of how to use the React Hook Form

Getting Started with my-reacthook-form You can get this project by running git clone https://github.com/ivandi1980/my-reacthook-form.git Available Scr

ivandjoh 3 Apr 4, 2022
Form next js 2022 - project for death valley.

Welcome to Death Valley 2022 base url https://form-next-js-2022-3snm4xixy-sungpah.vercel.app/ Download this repo git clone https://github.com/SUNGPA

SUNGPAH 2 Jul 1, 2022
💪🏽 Form creation made easy, backed by state machines

Elderform Form handling without tears and predictable form state based on defined parameters. Elderform gives you everything you need to create robust

Joshua 27 Nov 6, 2022
Easy HTML Form Validator

Easy HTML Form Validator

Ali Nazari 314 Dec 26, 2022
Facile is an HTML form validator that is inspired by Laravel's validation style and is designed for simplicity of use.

Facile is an HTML form validator that is inspired by Laravel's validation style and is designed for simplicity of use.

upjs 314 Dec 26, 2022
HTML 5 & Bootstrap Jquery Form Validation Plugin

HTML 5 & Bootstrap Jquery Form Validation Plugin HTML 5 & Bootstrap 5 & Jquery 3 jbvalidator is a fresh new jQuery based form validation plugin that i

null 37 Dec 6, 2022
Tag-input - A versetile tag input component built with Vue 3 Composition API

TagInput A versetile tag input component built with Vue 3 Composition API. Please read this article to learn how to build this package step by step an

Mayank 12 Oct 12, 2022
SmartContract UI Open source Blockchain's Smart Contract Tool

SmartContract UI Open source Blockchain's Smart Contract Tool Table of contents Homepage Features Usage Config ABI Import from deployed contract Selec

Martin Pham 12 Dec 16, 2022
Simple translation for your javascripts, yummy with your favorite templates engine like EJS.

jsperanto Simple translation for your javascripts, yummy with your favorite templates engine like EJS. Pluralization, interpolation & "nested lookup"

Jean-Philippe Joyal 62 Oct 21, 2021
Validate your forms, frontend, without writing a single line of javascript

Parsley JavaScript form validation, without actually writing a single line of JavaScript! Version 2.9.2 Doc See index.html and doc/ Requirements jQuer

Guillaume Potier 9k Dec 27, 2022
[DISCONTINUED] jQuery plugin that makes it easy to validate user input while keeping your HTML markup clean from javascript code.

jQuery Form Validator [DISCONTINUED] Validation framework that let's you configure, rather than code, your validation logic. I started writing this pl

Victor Jonsson 976 Dec 30, 2022