All Projects → jamescun → Legit

jamescun / Legit

Licence: bsd-2-clause
input validation framework

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Legit

Just Validate
Lightweight (~4,5kb gzip) form validation in Javascript Vanilla, without dependencies, with customizable rules (including remote validation), customizable messages and customizable submit form with ajax helper.
Stars: ✭ 74 (-8.64%)
Mutual labels:  validation, form-validation, form
Usetheform
React library for composing declarative forms, manage their state, handling their validation and much more.
Stars: ✭ 40 (-50.62%)
Mutual labels:  validation, form-validation, form
Formhelper
ASP.NET Core - Transform server-side validations to client-side without writing any javascript code. (Compatible with Fluent Validation)
Stars: ✭ 155 (+91.36%)
Mutual labels:  validation, form-validation, form
React Form With Constraints
Simple form validation for React
Stars: ✭ 117 (+44.44%)
Mutual labels:  validation, form-validation, form
svelte-form
JSON Schema form for Svelte v3
Stars: ✭ 47 (-41.98%)
Mutual labels:  validation, form, form-validation
Form Validation.js
The most customizable validation framework for JavaScript.
Stars: ✭ 127 (+56.79%)
Mutual labels:  validation, form-validation, form
Ok
✔️ A tiny TypeScript library for form validation
Stars: ✭ 34 (-58.02%)
Mutual labels:  validation, form-validation, form
Neoform
✅ React form state management and validation
Stars: ✭ 162 (+100%)
Mutual labels:  validation, form-validation, form
formalizer
React hooks based form validation made for humans.
Stars: ✭ 12 (-85.19%)
Mutual labels:  validation, form, form-validation
Resolvers
📋 Validation resolvers: Zod, Yup, Joi, Superstruct, and Vest.
Stars: ✭ 222 (+174.07%)
Mutual labels:  validation, form-validation, form
Formsy React
A form input builder and validator for React JS
Stars: ✭ 708 (+774.07%)
Mutual labels:  validation, form-validation, form
React Hook Form
📋 React Hooks for form state management and validation (Web + React Native)
Stars: ✭ 24,831 (+30555.56%)
Mutual labels:  validation, form-validation, form
Bootstrap Validate
A simple Form Validation Library for Bootstrap 3 and Bootstrap 4 not depending on jQuery.
Stars: ✭ 112 (+38.27%)
Mutual labels:  validation, form-validation, form
React Final Form
🏁 High performance subscription-based form state management for React
Stars: ✭ 6,781 (+8271.6%)
Mutual labels:  validation, form-validation, form
Redux Form
A Higher Order Component using react-redux to keep form state in a Redux store
Stars: ✭ 12,597 (+15451.85%)
Mutual labels:  validation, form-validation, form
Approvejs
A simple JavaScript validation library that doesn't interfere
Stars: ✭ 336 (+314.81%)
Mutual labels:  validation, form-validation, form
Bunny
BunnyJS - Lightweight native (vanilla) JavaScript (JS) and ECMAScript 6 (ES6) browser library, package of small stand-alone components without dependencies: FormData, upload, image preview, HTML5 validation, Autocomplete, Dropdown, Calendar, Datepicker, Ajax, Datatable, Pagination, URL, Template engine, Element positioning, smooth scrolling, routing, inversion of control and more. Simple syntax and architecture. Next generation jQuery and front-end framework. Documentation and examples available.
Stars: ✭ 473 (+483.95%)
Mutual labels:  validation, form-validation, form
Vue Form
Form validation for Vue.js 2.2+
Stars: ✭ 618 (+662.96%)
Mutual labels:  validation, form-validation
Hyperform
Capture form validation back from the browser
Stars: ✭ 729 (+800%)
Mutual labels:  validation, form-validation
Vvalidator
🤖 An easy to use form validator for Kotlin & Android.
Stars: ✭ 592 (+630.86%)
Mutual labels:  validation, form
LEGIT

GoDoc

Legit is an input validation framework for Go. Legit differs from existing frameworks by constructing validation from types and interfaces, preferring custom validators to complex struct tags.

go get -u github.com/jamescun/legit

Included validators:

  • Email
  • UUID
  • UUID3
  • UUID4
  • UUID5
  • Credit Card
  • Lowercase
  • Uppercase
  • No whitespace
  • Printable characters
  • Alpha
  • Alphanumeric
  • Numeric
  • ASCII
  • Positive number
  • Negative number

Example

package main

import (
	"fmt"
	"net/http"

	"github.com/jamescun/legit"
)

type User struct {
	Email legit.Email    `json:"email"`
	Age   legit.Positive `json:"age"`
}

func Handler(w http.ResponseWriter, r *http.Request) {
	var user User
	err := legit.ParseRequestAndValidate(r, &user)
	if err != nil {
		fmt.Fprintln(w, "invalid user:", err)
		return
	}
}

Custom Example

package main

import (
	"fmt"
	"regexp"
	"errors"
	"encoding/json"

	"github.com/jamescun/legit"
)

type Name string

// very simplistic regexp for human name validation
var expName = regexp.MustCompile(`[a-zA-Z\ ]{1,64}`)

// attach Validate() method to our custom name type, satisfying the legit.Object interface,
// defining our custom name validation.
func (n Name) Validate() error {
	if !expName.MatchString(string(n)) {
		return errors.New("invalid name")
	}

	return nil
}

type User struct {
	Email legit.Email `json:"email"`
	Name  Name        `json:"name"`
}

func main() {
	body := []byte(`{"email": "[email protected]", "name": "John Doe"}`)
	
	var user User
	json.Unmarshal(body, &user)

	err := legit.Validate(user)
	if err != nil {
		fmt.Println("invalid user!", err)
	}
}

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