Skip to main content
Version: 2.8.x(Latest)

Introduction

The goframe framework provides a powerful, easy-to-use, flexible, and easily extensible data/form validation component implemented by the gvalid component. The gvalid component implements a very powerful data validation functionality, with dozens of built-in common validation rules. It supports single data multiple rule validation, multi-data multi-rule batch validation, custom error messages, custom regular expression validation, custom validation rule registration, supports i18n internationalization processing, supports struct tag rules and prompt information binding and other features, making it currently the most powerful Go data validation module.

tip

The design inspiration for data validation comes from the classic PHP Laravel framework https://laravel.com/docs/8.x/validation. Thank you Laravel ❤️

Usage

import "github.com/gogf/gf/v2/util/gvalid"

API Documentation

https://pkg.go.dev/github.com/gogf/gf/v2/util/gvalid

Features

The gvalid component has the following notable features:

  • Built-in dozens of common data validation rules, supporting most business scenarios
  • Supports Server layer and command-line component automated validation
  • Supports basic types and complex object type parameter validation
  • Supports sequential validation and flexible validation result handling
  • Supports custom validation error messages
  • Supports recursive validation of struct attributes
  • Supports custom validation rules
  • Supports internationalization feature I18n

Documents

📄️ Data Validation - Rules

Data validation rules and their applications in the GoFrame framework. The GoFrame framework comes with multiple commonly used validation rules, assisting developers in parameter validation and struct validation when processing data. The article provides a detailed explanation of how to use various validation rules in different scenarios, including required parameters, date formats, numeric ranges, enumeration validation, etc., offering developers a flexible validation mechanism.

📄️ Data Validation - Optional Rule

Using the GoFrame framework for data validation, especially focusing on the use of optional validation rules. When the validation rules do not include 'required', optional validation rules do not enforce validation on empty strings or nil values. The document provides multiple practical code examples to demonstrate the process and considerations for implementing optional data validation with the GoFrame framework in Go language, suitable for developers to apply in projects.