All Projects → rootstrap → validate

rootstrap / validate

Licence: MIT License
An extension to the popular library validate.js that adds some useful custom validations out of the box. Also, a hub for all custom validations, that we have created, so you can easily add them to your own project.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to validate

Approvejs
A simple JavaScript validation library that doesn't interfere
Stars: ✭ 336 (+983.87%)
Mutual labels:  form, form-validation, javascript-library, validations
FilterInputJs
Tiny and Powerful Library for limit an entry (text box,input) as number,string or more...
Stars: ✭ 37 (+19.35%)
Mutual labels:  form-validation, javascript-library, validations
react-inputs-validation
A react component for form inputs validation. Online demo examples
Stars: ✭ 48 (+54.84%)
Mutual labels:  form, form-validation
ATGValidator
iOS validation framework with form validation support
Stars: ✭ 51 (+64.52%)
Mutual labels:  form, form-validation
antd-react-form-builder
Example
Stars: ✭ 74 (+138.71%)
Mutual labels:  form, 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 (+670.97%)
Mutual labels:  form, form-validation
Final Form
🏁 Framework agnostic, high performance, subscription-based form state management
Stars: ✭ 2,787 (+8890.32%)
Mutual labels:  form, form-validation
ember-validity-modifier
Ember Octane addon to add custom validity (form validation) to form fields
Stars: ✭ 28 (-9.68%)
Mutual labels:  form, form-validation
Redux Form
A Higher Order Component using react-redux to keep form state in a Redux store
Stars: ✭ 12,597 (+40535.48%)
Mutual labels:  form, form-validation
react-cool-form
😎 📋 React hooks for forms state and validation, less code more performant.
Stars: ✭ 246 (+693.55%)
Mutual labels:  form, form-validation
form-data-json
A zero dependency, cross browser library to easily get or set/manipulate form input values as/from a json object.
Stars: ✭ 37 (+19.35%)
Mutual labels:  form, form-validation
autoform
🤖📝 AutoForm is the simplest way to automatically generate fast, beautiful and standards/WCAG compliant HTML forms based on an Ecto Schema in a Phoenix Web Application to *significantly* speed up Web App Development. 🚀
Stars: ✭ 18 (-41.94%)
Mutual labels:  form, form-validation
Resolvers
📋 Validation resolvers: Zod, Yup, Joi, Superstruct, and Vest.
Stars: ✭ 222 (+616.13%)
Mutual labels:  form, form-validation
Material Singleinputform
A single EditText instead of a classical form. Library that implements flavienlaurent's singleinputform
Stars: ✭ 202 (+551.61%)
Mutual labels:  form, form-validation
FrontendForms
A module for ProcessWire CMS to create and validate forms on the frontend easily using the Valitron library.
Stars: ✭ 0 (-100%)
Mutual labels:  form, form-validation
Elm Form
Dynamic forms handling in Elm
Stars: ✭ 189 (+509.68%)
Mutual labels:  form, form-validation
vue-use-form
✅ A Vue.js composition API function to validate forms
Stars: ✭ 97 (+212.9%)
Mutual labels:  form, form-validation
Sveltejs Forms
Declarative forms for Svelte
Stars: ✭ 163 (+425.81%)
Mutual labels:  form, form-validation
Composable Form
Build type-safe composable forms in Elm
Stars: ✭ 179 (+477.42%)
Mutual labels:  form, form-validation
react-useForm
World's simplest React hook to manage form state
Stars: ✭ 30 (-3.23%)
Mutual labels:  form, form-validation

@rootstrap/validate

Maintainability Test Coverage

Have you ever had to write your own custom validations? It can be a bit confusing, specially if you have never done it before. Don't worry, we are here to help.

This library extends the popular library validate.js and adds some custom validations that have proven to be very useful and quite commonly needed. Don't reinvent the wheel, next time you need to write a custom validation, check if someone hasn't implemented that custom validation already.

Aside from common custom validations, this library will also serve as a gallery of all the custom validations that we have had to implement at Rootstrap, although some might not be included out of the box, we intend to showcase them in case you need them. Here is a link to said gallery

If you need a validation that is not in this library you might be wondering, where do I even start? I've never written a custom validation. Don't worry, we got you covered! We have made available a tutorial so it's easier to understand how to create a custom validation. Don't forget to check out other custom validations in the gallery, they can be really helpful when implementing your own as well.

Installation

yarn add @rootstrap/validate

or

npm install @rootstrap/validate --save

Usage of custom validators

Just in case, if you are just trying to figure out how a validate.js validator works, here is a link to their docs. This library only explains the validators it adds.

conditionalConstraints

This validators allows you to validate certain constraints on a field, given that other fields meet certain validations.

As an example, it would be useful when trying to validate that a field is present only if a checkbox is checked or not checked. Sounds like a very common use case right? Here is how you can use the validator conditionalConstraints to achieve that.

// createNewElement is a checkbox
// If createNewElement is true:
// then validate checks the constraints assigned to new element
// else
// validate skips the assigned constraints inside conditional constraints.
const myFancyFormConstraints = {
  newElementName: {
    conditionalConstraints: {
      dependencies: [
        { attribute: 'createNewElement', constraints: { presence: true } },
      ],
      constraints: {
        presence: true,
      },
    },
  },
};

noPresence

This constraint is more of a helper to conditionalConstraints than anything else. When checking a field with some conditionalConstraints you might want to have as a dependency a field actually not being present.

Let's take the same example that conditionalConstraints has but now let's change the checkbox to useCurrentElement. With that change, now the new element field would only be required if useCurrentElement is not present.

In case you want to check that a field is not present, the constraint inside the constraints of the dependency should look like:

noPresence: true;

Optionally, if you want to include false values in the check, you can do so by setting this in the options like this:

presence: {
  includeFalse: true;
}

Full example:

// useCurrentElement is a checkbox
// If useCurrentElement is not present or false:
// then validate checks the constraints assigned to new element
// else
// validate skips the assigned constraints inside conditional constraints.
const myFancyFormConstraints = {
  newElementName: {
    conditionalConstraints: {
      dependencies: [
        {
          attribute: 'useCurrentElement',
          constraints: { noPresence: { includeFalse: true } },
        },
      ],
      constraints: {
        presence: true,
      },
    },
  },
};

Contributing

If you have an idea that could make this library better we would love to hear it. Please take a look at our Contributing Guidelines to get to know the rules and how to get started with your contribution.

License

@rootstrap/validate is available under the MIT license. See LICENSE file for more info.

Credits

@rootstrap/validate is maintained by Rootstrap with the help of our contributors.

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].