Suggestion for a dynamic Struct Validation Rules

This page summarizes the projects mentioned and recommended in the original post on /r/golang

Our great sponsors
  • WorkOS - The modern API for authentication & user identity.
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • Onboard AI - ChatGPT with full context of any GitHub repo.
  • validator

    :100:Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving

    github.com/go-playground/validator/ has a bug with nested struct which breaks. Also somewhat limited Ruleset it seems.

  • ozzo-validation

    An idiomatic Go (golang) validation package. Supports configurable and extensible validation rules (validators) using normal language constructs instead of error-prone struct tags.

    https://github.com/go-ozzo/ozzo-validation Seems to do what I need but likely will need some convoluted reflection to build out the rules. Also likely some custom rules to be written which is okay since it's a one time cost and reuse in the expressions.

  • WorkOS

    The modern API for authentication & user identity. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

  • expr

    Expression language and expression evaluation for Go [Moved to: https://github.com/expr-lang/expr] (by antonmedv)

    https://github.com/antonmedv/expr/ Seems really promising though having a rough time finding examples or basic do something as simple as struct.Value == N though I did find some examples on iterating and such.

  • cel-go

    Fast, portable, non-Turing complete expression evaluation with gradual typing (Go)

    https://github.com/google/cel-go Didn't find much support for structs.

  • otto

    A JavaScript interpreter in Go (golang)

    Otto https://github.com/robertkrimen/otto Seems interesting. It lets me call Go functions from inside JS as well as return results. The fncs pattern reminds me a bit of how the template engine works.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts