proxy.golang.org : github.com/krizmak/funcvalid
Package funcvalid is a tiny validator package in functional style. Unlike the usual go validators, it does not rely on the tag feature of the structs, because they don't benefit from the type safety that golang types ensures. So funcvalid package: The main concept is that a validator is simply a function that takes an input and returns an error if the validation is unsuccessful or nil, if it is successful. It doesn't seem very useful until now, because in most of the cases the validators need a parameter, too. This package provides factory functions, that may take arguments and return a validator. It works a bit like currying in functional languages hence the name. The idea comes from this excellent curry post. If it still sounds a bit cryptic, let's see the following example: The actual factory functions are even a bit more generak by using generic types. The package also provides Not, Or and And factory functions with that you can chain other validators. For further details see the documentation of the functions, and have a functional fun in Go! I've copied/reworked most of the built-in validators from the validator package, that is the best of the tag based validators. Factory functions composed from Regexp factory function and regexp collection from https://github.com/go-playground/validator
Registry
-
Source
- Documentation
- JSON
purl: pkg:golang/github.com/krizmak/funcvalid
License: MIT
Latest release: over 1 year ago
First release: almost 2 years ago
Namespace: github.com/krizmak
Stars: 0 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 1 day ago