Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sundowndev
GitHub Repository: sundowndev/phoneinfoga
Path: blob/master/web/validators.go
988 views
1
package web
2
3
import (
4
errors2 "errors"
5
"github.com/gin-gonic/gin"
6
"github.com/sundowndev/phoneinfoga/v2/web/errors"
7
)
8
9
// JSONResponse is the default API response type
10
type JSONResponse struct {
11
Success bool `json:"success"`
12
Error string `json:"error,omitempty"`
13
Message string `json:"message,omitempty"`
14
}
15
16
type scanURL struct {
17
Number uint `uri:"number" binding:"required,min=2"`
18
}
19
20
// ValidateScanURL validates scan URLs
21
func ValidateScanURL(c *gin.Context) {
22
var v scanURL
23
if err := c.ShouldBindUri(&v); err != nil {
24
handleError(c, errors.NewBadRequest(errors2.New("the given phone number is not valid")))
25
}
26
}
27
28