Code Monkey home page Code Monkey logo

validating's Introduction

validating

A Go library for validating structs, maps and slices.

Features

  1. Simple

    Simple and stupid, no magic involved.

  2. Type-safe

    Schema is defined in Go, which is type-safer (and more powerful) than traditional struct tags.

  3. Flexible

    • Validators are composable.
    • Nested struct validation is well supported.
    • Schema can be defined inside or outside struct.
    • Validator customizations are made easy.
  4. No reflection

Installation

$ go get github.com/RussellLuo/validating/v3@latest

Validator factories and validators

To be strict, this library has a conceptual distinction between validator factory and validator.

A validator factory is a function used to create a validator, which will do the actual validation.

Built-in validator factories

Extension validator factories

Validator customizations

Examples

Documentation

Check out the Godoc.

Thanks

This library borrows some ideas from the following libraries:

License

MIT

validating's People

Contributors

dolmen avatar russellluo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

validating's Issues

[validator] would it be ok to have more business oriented validators?

Hello !

First of all, thanks a lot for this library ! :)

I was wondering if you would be open to PR introducing more business oriented validators to be used by higher level applications. I a; think of validators such as:

  • email
  • phone number
  • website
  • etc

If it makes sense to you, I am whiling to work on this PR :)

Thanks !

Enrich error messages

Any chance you could extend MessageValidator with a function where I can set a custom error instead of just a string? So in addition to .Msg(s string) something like .Err(err error)? My errors contain additional information which would allow me further processing after validation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.