Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023, 2024 Mikolaj Gasior <m@gasior.dev>
Copyright (c) 2023, 2024, 2025 Mikołaj Gąsior <m@gasior.dev>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
# structvalidator

[![Go Reference](https://pkg.go.dev/badge/github.com/keenbytes/structvalidator.svg)](https://pkg.go.dev/github.com/keenbytes/structvalidator) [![Go Report Card](https://goreportcard.com/badge/github.com/keenbytes/structvalidator)](https://goreportcard.com/report/github.com/keenbytes/structvalidator)
# struct-validator

Verify the values of struct fields using tags

### Example code

Use the package with the following URL:
```
import "github.com/keenbytes/structvalidator"
import "github.com/keenbytes/struct-validator"
```

And see below code snippet:
And see the below code snippet:
```
type Test1 struct {
FirstName string `validation:"req lenmin:5 lenmax:25"`
Expand All @@ -31,7 +29,7 @@ s := &Test1{
...
}

o := structvalidator.&ValidationOptions{
o := validator.&ValidationOptions{
RestrictFields: map[string]bool{
"FirstName": true,
"LastName": true,
Expand All @@ -40,5 +38,5 @@ o := structvalidator.&ValidationOptions{
...
}

isValid, fieldsWithInvalidValue := structvalidator.Validate(s, &o)
isValid, fieldViolations, err := validator.Validate(s, &o)
```
17 changes: 17 additions & 0 deletions consts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package validator

import "regexp"

const (
FailLenMin = 2 << iota
FailLenMax
FailValMin
FailValMax
FailRegExp
FailEmail
FailReq
FailType
)

// pre‑compiled e‑mail regexp (RFC‑5322‑ish, good enough for most cases)
var emailRegexp = regexp.MustCompile(`^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$`)
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/keenbytes/structvalidator
module github.com/keenbytes/struct-validator

go 1.22.1
go 1.24.5
212 changes: 0 additions & 212 deletions html_input_gen.go

This file was deleted.

112 changes: 0 additions & 112 deletions html_input_gen_test.go

This file was deleted.

Loading
Loading