kat-co / Vala
Licence: mit
A simple, extensible, library to make argument validation in Go palatable.
Stars: ✭ 109
Programming Languages
go
31211 projects - #10 most used programming language
Labels
Projects that are alternatives of or similar to Vala
React Inform
Simple controlled forms with validations in react
Stars: ✭ 81 (-25.69%)
Mutual labels: validation
Validates timeliness
Date and time validation plugin for ActiveModel and Rails. Supports multiple ORMs and allows custom date/time formats.
Stars: ✭ 1,319 (+1110.09%)
Mutual labels: validation
Accept values for
Rspec matchers to test ActiveModel validation that follows BDD.
Stars: ✭ 103 (-5.5%)
Mutual labels: validation
React Native Merlin
🧙 Simple web-like forms in react native.
Stars: ✭ 83 (-23.85%)
Mutual labels: validation
Validator Collection
Python library of 60+ commonly-used validator functions
Stars: ✭ 91 (-16.51%)
Mutual labels: validation
Graphql Go Tools
Tools to write high performance GraphQL applications using Go/Golang.
Stars: ✭ 96 (-11.93%)
Mutual labels: validation
Vue Rawmodel
RawModel.js plugin for Vue.js v2. Form validation has never been easier!
Stars: ✭ 79 (-27.52%)
Mutual labels: validation
Validator
Drop in user input validation for your iOS apps.
Stars: ✭ 1,444 (+1224.77%)
Mutual labels: validation
Ngx Dynamic Form Builder
FormBuilder + class-transformer + class-validator = dynamic form group builder for Angular10+
Stars: ✭ 93 (-14.68%)
Mutual labels: validation
Gltf Asset Generator
Tool for generating various glTF assets for importer validation
Stars: ✭ 103 (-5.5%)
Mutual labels: validation
Filetype
Fast, dependency-free, small Go package to infer the binary file type based on the magic numbers signature
Stars: ✭ 1,278 (+1072.48%)
Mutual labels: validation
Fluidvalidator
General purpose validation system for objects, nested objects, enumerables written in Swift
Stars: ✭ 89 (-18.35%)
Mutual labels: validation
Angular Multi Step Wizard
Tutorials on building an Angular 4 Multi-Step Wizard with its own Router
Stars: ✭ 96 (-11.93%)
Mutual labels: validation
Protoc Gen Validate
protoc plugin to generate polyglot message validators
Stars: ✭ 1,241 (+1038.53%)
Mutual labels: validation
Postguard
🐛 Statically validate Postgres SQL queries in JS / TS code and derive schemas.
Stars: ✭ 104 (-4.59%)
Mutual labels: validation
Flask pydantic
flask extension for integration with the awesome pydantic package
Stars: ✭ 96 (-11.93%)
Mutual labels: validation
Validatorjs
A data validation library in JavaScript for the browser and Node.js, inspired by Laravel's Validator.
Stars: ✭ 1,534 (+1307.34%)
Mutual labels: validation
Ymate Platform V2
YMP是一个非常简单、易用的轻量级Java应用开发框架,涵盖AOP、IoC、WebMVC、ORM、Validation、Plugin、Serv、Cache等特性,让开发工作像搭积木一样轻松!
Stars: ✭ 106 (-2.75%)
Mutual labels: validation
Play2 Html5tags
HTML5 form tags module for Play Framework
Stars: ✭ 101 (-7.34%)
Mutual labels: validation
vala
A simple, extensible, library to make argument validation in Go palatable.
Instead of this:
func BoringValidation(a, b, c, d, e, f, g MyType) {
if (a == nil)
panic("a is nil")
if (b == nil)
panic("b is nil")
if (c == nil)
panic("c is nil")
if (d == nil)
panic("d is nil")
if (e == nil)
panic("e is nil")
if (f == nil)
panic("f is nil")
if (g == nil)
panic("g is nil")
}
Do this:
func ClearValidation(a, b, c, d, e, f, g MyType) {
BeginValidation().Validate(
IsNotNil(a, "a"),
IsNotNil(b, "b"),
IsNotNil(c, "c"),
IsNotNil(d, "d"),
IsNotNil(e, "e"),
IsNotNil(f, "f"),
IsNotNil(g, "g"),
).CheckAndPanic() // All values will get checked before an error is thrown!
}
Instead of this:
func BoringValidation(a, b, c, d, e, f, g MyType) error {
if (a == nil)
return fmt.Errorf("a is nil")
if (b == nil)
return fmt.Errorf("b is nil")
if (c == nil)
return fmt.Errorf("c is nil")
if (d == nil)
return fmt.Errorf("d is nil")
if (e == nil)
return fmt.Errorf("e is nil")
if (f == nil)
return fmt.Errorf("f is nil")
if (g == nil)
return fmt.Errorf("g is nil")
}
Do this:
func ClearValidation(a, b, c, d, e, f, g MyType) (err error) {
defer func() { recover() }
BeginValidation().Validate(
IsNotNil(a, "a"),
IsNotNil(b, "b"),
IsNotNil(c, "c"),
IsNotNil(d, "d"),
IsNotNil(e, "e"),
IsNotNil(f, "f"),
IsNotNil(g, "g"),
).CheckSetErrorAndPanic(&err) // Return error will get set, and the function will return.
// ...
VeryExpensiveFunction(c, d)
}
Tier your validation:
func ClearValidation(a, b, c MyType) (err error) {
err = BeginValidation().Validate(
IsNotNil(a, "a"),
IsNotNil(b, "b"),
IsNotNil(c, "c"),
).CheckAndPanic().Validate( // Panic will occur here if a, b, or c are nil.
HasLen(a.Items, 50, "a.Items"),
GreaterThan(b.UserCount, 0, "b.UserCount"),
Equals(c.Name, "Vala", "c.name"),
Not(Equals(c.FriendlyName, "Foo", "c.FriendlyName")),
).Check()
if err != nil {
return err
}
// ...
VeryExpensiveFunction(c, d)
}
Extend with your own validators for readability. Note that an error should always be returned so that the Not function can return a message if it passes. Unlike idiomatic Go, use the boolean to check for success.
func ReportFitsRepository(report *Report, repository *Repository) Checker {
return func() (passes bool, err error) {
err = fmt.Errof("A %s report does not belong in a %s repository.", report.Type, repository.Type)
passes = (repository.Type == report.Type)
return passes, err
}
}
func AuthorCanUpload(authorName string, repository *Repository) Checker {
return func() (passes bool, err error) {
err = fmt.Errof("%s does not have access to this repository.", authorName)
passes = !repository.AuthorCanUpload(authorName)
return passes, err
}
}
func AuthorIsCollaborator(authorName string, report *Report) Checker {
return func() (passes bool, err error) {
err = fmt.Errorf("The given author was not one of the collaborators for this report.")
for _, collaboratorName := range report.Collaborators() {
if collaboratorName == authorName {
passes = true
break
}
}
return passes, err
}
}
func HandleReport(authorName string, report *Report, repository *Repository) {
BeginValidation().Validate(
AuthorIsCollaborator(authorName, report),
AuthorCanUpload(authorName, repository),
ReportFitsRepository(report, repository),
).CheckAndPanic()
}
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].