func (l CreateLinkRequest) Validate(maxlength int, serverHost string) error {
	err := validation.ValidateStruct(&l,
		// URL must not be empty and a valid URL
		validation.Field(&l.URL, validation.Required, is.URL),
		// ID cannot be empty, the length must be below configured max, and must be in correct format
		validation.Field(&l.ID,
			validation.Required, validation.Length(1, maxlength), validation.By(checkValidID)),
	)
	if err != nil {
		return err
	}

	url, _ := url.Parse(l.URL)
	if serverHost == url.Host {
		return errors.New("redirect loop detected")
	}

	return nil
}
// Validate checks URL and ID to make sure they are valid and conform to standards
Validate checks URL and ID to make sure they are valid and conform to standards
// Validate checks URL and ID to make sure they are valid and conform to standards
func (l CreateLinkRequest) Validate(maxlength int, serverHost string) error {
	err := validation.ValidateStruct(&l,
		validation.Field(&l.URL, validation.Required, is.URL),
		validation.Field(&l.ID,
			validation.Required, validation.Length(1, maxlength), validation.By(checkValidID)),
	)
	if err != nil {
		return err
	}
	url, _ := url.Parse(l.URL)
	if serverHost == url.Host {
		return errors.New("redirect loop detected")
	}
	return nil
}
func ( l CreateLinkRequest ) Validate ( maxlength int , serverHost string ) error { err := validation . ValidateStruct ( & l , validation . Field ( & l . URL , validation . Required , is . URL ) , validation . Field ( & l . ID , validation . Required , validation . Length ( 1 , maxlength ) , validation . By ( checkValidID ) ) , ) if err != nil { return err } url , _ := url . Parse ( l . URL ) if serverHost == url . Host { return errors . New ( " " ) } return nil }
Validate checks URL and ID to make sure they are valid and conform to standards
Validate checks URL and ID to make sure they are valid and conform to standards
// URL must not be empty and a valid URL // ID cannot be empty, the length must be below configured max, and must be in correct format