A Go library for trimming, sanitizing, and formatting struct string fields in place using struct tags.
Conform is a Go library that automatically trims, sanitizes, and formats string fields in structs based on struct tags. It solves the problem of cleaning and standardizing user input (like names, emails, or slugs) without writing custom formatting functions for each field.
Go developers handling form processing, API input validation, or any scenario where user-provided string data needs consistent formatting before storage or further processing.
Developers choose Conform for its simplicity and declarative approach—using struct tags to define transformations reduces boilerplate code and ensures consistent data formatting across an application.
Trims, sanitizes & scrubs data based on struct tags (go, golang)
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses simple `conform:"tag"` struct tags to define transformations, eliminating repetitive boilerplate code for cleaning user input, as shown in the README examples.
Includes a wide range of tags for trimming, case conversion (e.g., camel, snake, slug), and sanitization (e.g., name, email, !html), covering common formatting needs without custom functions.
Works alongside Gorilla Schema tags for combined decoding and sanitization, allowing developers to clean form data in the same struct pointer, as demonstrated in the README.
Handles slices of strings and map values (though not keys), and supports embedded structs, enabling thorough cleaning of nested or aggregated string data.
Modifies struct fields directly via `conform.Strings(&struct)`, permanently overwriting original input, which risks data loss if not carefully managed or if cleanup is applied multiple times.
Exclusively processes string fields, ignoring other types like numbers or dates; for non-string data cleaning, developers must implement separate logic, limiting its scope.
As the README admits, it focuses only on formatting and sanitization, requiring integration with external libraries like govalidator for actual validation, adding complexity to the stack.
Some transformers, such as camel case, rely on third-party libraries (e.g., stringUp), introducing potential dependency issues or maintenance overhead compared to self-contained solutions.