send all files

This commit is contained in:
2024-07-21 00:15:14 -03:00
parent 1e8cda0139
commit c9464c4a6f
72 changed files with 6335 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
package authdto
import (
"api/libs/logger"
"errors"
"github.com/go-playground/validator/v10"
)
type AuthDto struct {
Username string `json:"username" validate:"required"`
Password string `json:"password" validate:"required"`
}
func (d *AuthDto) Validate() error {
validate := validator.New()
err := validate.Struct(d)
if err != nil {
// this check is only needed when your code could produce
// an invalid value for validation such as interface with nil
// value most including myself do not usually have code like this.
if _, ok := err.(*validator.InvalidValidationError); ok {
logger.Development.Info(err.Error())
}
for _, e := range err.(validator.ValidationErrors) {
err = errors.New(e.Field() + " " + e.Tag())
}
}
return err
}