
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
github.com/forkyid/go-utils/validation
Makes use of four field tags: validate
, id
, process
, json
json
is used to get the field name when processing error details. If this tag is empty, or "-", the name defaults to the lowercased struct field name. Returns 400 on error.
validate
tags is passed to go-validator. Errors from go-validator is parsed into validation.ErrorDetails.
"id"
tags has three possible values: "required"
, "valid"
, "allow-zero"
, and "dive"
. "required"
validates that the field is not empty, and is valid, sets the status code to 400 when empty and 422 when invalid. "valid"
behaves similarly to "required"
but returns 200 when empty. "allow-zero"
allows zero value in id. When used on a slice, the tags will be applied to each element. Using the "dive"
tag instructs the validator to recursively dive into slices, maps, and structs. The validator then checks for other tags within the slice/map/struct.
"process"
behaves in the same way as validate but returns 422 on error.
validation.ErrorDetails
is a map[string]string with an additional method Add(key, value string)
. Appends detail with "|" as separator. This type can be directly passed to rest.ResponseError
as details.
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
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.