Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add gen idea infra point #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

feat: add gen idea infra point #2

wants to merge 1 commit into from

Conversation

9ssi7
Copy link
Owner

@9ssi7 9ssi7 commented Feb 19, 2025

may close #1

intended useges

basic usage

package model

//go:generate rapidval -all $GOFILE
type User struct {
	ID       int64  `json:"id" validate:"min=1"`
	Username string `json:"username" validate:"required,min=3,max=50"`
	Email    string `json:"email" validate:"required,email"`
	Age      int    `json:"age" validate:"min=0,max=150"`
	IsActive bool   `json:"is_active"`
}

usage with easyjson

package model

//go:generate rapidval -all $GOFILE
//go:generate easyjson -all $GOFILE
type User struct {
	ID       int64  `json:"id" validate:"min=1"`
	Username string `json:"username" validate:"required,min=3,max=50"`
	Email    string `json:"email" validate:"required,email"`
	Age      int    `json:"age" validate:"min=0,max=150"`
	IsActive bool   `json:"is_active"`
}

its generates user_validate.go. Pre-defined validation function for model with validations as provided in struct tags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

more useful and performanced usage
1 participant