
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
github.com/danangkonang/validation
package main
import (
"encoding/json"
"fmt"
"github.com/danangkonang/validation"
)
func main() {
type Children struct {
Level string `json:"level" enum:"beginner,intermediate,advanced"`
}
type T struct {
Username string `json:"username" validate:"required,email"`
Password string `json:"password" validate:"min=20"`
ConfirmPassword string `json:"confirm_password" validate:"eqfield=Password"`
Children []Children `json:"children" validate:"required"`
}
data := T{
Username: "",
Password: "foo",
ConfirmPassword: "bar",
Children: []Children{
{
Level: "",
},
},
}
v := validation.New()
customMessage := map[string]string{
"required": "your custom message",
"min": "minimum {{.}} char",
}
v.SetLanguage(customMessage)
ValidationErrorMessage, err := v.Validate(data)
if err != nil {
userJson, _ := json.Marshal(ValidationErrorMessage)
fmt.Println(string(userJson))
// [
// {
// "key": "username",
// "message": [
// "This field is required",
// "This field must be a valid email address"
// ]
// },
// {
// "key": "password",
// "message": [
// "This field must be a minimum 20"
// ]
// },
// {
// "key": "confirm_password",
// "message": [
// "This field must be a equal with password"
// ]
// },
// {
// "key": "children",
// "message": [
// {
// "key": "level",
// "message": [
// "This field must be one of [beginner,intermediate,advanced]"
// ]
// }
// ]
// }
// ]
}
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.