You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that we have to duplicate the SKU pattern both in the documentation:
typeProductstruct {
...// the SKU for the product//// required: true// pattern: [a-z]+-[a-z]+-[a-z]+SKUstring`json:"sku" validate:"sku"`
}
and the validation function:
funcvalidateSKU(fl validator.FieldLevel) bool {
// SKU must be in the format abc-abc-abcre:=regexp.MustCompile(`[a-z]+-[a-z]+-[a-z]+`)
In Clojure, I would create a spec (schema) that could be reused both in documentation and the validation. How can we achieve something similar in Go to avoid duplicating these patterns?
The text was updated successfully, but these errors were encountered:
I noticed that we have to duplicate the SKU pattern both in the documentation:
and the validation function:
In Clojure, I would create a spec (schema) that could be reused both in documentation and the validation. How can we achieve something similar in Go to avoid duplicating these patterns?
The text was updated successfully, but these errors were encountered: