package repository

import (
	"fmt"

	"gopkg.in/asaskevich/govalidator.v6"
)

func ValidateCreate(r *Repository) error {
	if err := validateName(r.Name); err != nil {
		return err
	}

	if err := validateDescription(r.Description); err != nil {
		return err
	}

	if err := validateWebsite(r.Website); err != nil {
		return err
	}

	return nil
}

func validateID(id string) error {
	if ok := govalidator.IsUUIDv4(id); !ok {
		return fmt.Errorf("id is not a valid uuid v4")
	}
	return nil
}

func validateName(name string) error {
	if ok := govalidator.IsAlphanumeric(name); !ok {
		return fmt.Errorf("name is not alphanumeric")
	}
	if ok := govalidator.IsByteLength(name, 4, 32); !ok {
		return fmt.Errorf("name is not between 4 and 32 characters long")
	}
	return nil
}

func validateDescription(description string) error {
	return nil
}

func validateWebsite(website string) error {
	if ok := govalidator.IsURL(website); !ok {
		return fmt.Errorf("%s is not a url", website)
	}

	return nil
}

package repository

import (
	"fmt"

	"gopkg.in/asaskevich/govalidator.v6"
)

func ValidateCreate(r *Repository) error {
	if err := validateName(r.Name); err != nil {
		return err
	}

	if err := validateDescription(r.Description); err != nil {
		return err
	}

	if err := validateWebsite(r.Website); err != nil {
		return err
	}

	return nil
}

func validateID(id string) error {
	if ok := govalidator.IsUUIDv4(id); !ok {
		return fmt.Errorf("id is not a valid uuid v4")
	}
	return nil
}

func validateName(name string) error {
	if ok := govalidator.IsAlphanumeric(name); !ok {
		return fmt.Errorf("username is not alphanumeric")
	}
	if ok := govalidator.IsByteLength(name, 4, 32); !ok {
		return fmt.Errorf("username is not between 4 and 32 characters long")
	}
	return nil
}

func validateDescription(description string) error {
	return nil
}

func validateWebsite(website string) error {
	if ok := govalidator.IsURL(website); !ok {
		return fmt.Errorf("%s is not a url", website)
	}

	return nil
}

--- 
+++ 
@@ -31,10 +31,10 @@
 
 func validateName(name string) error {
 	if ok := govalidator.IsAlphanumeric(name); !ok {
-		return fmt.Errorf("username is not alphanumeric")
+		return fmt.Errorf("name is not alphanumeric")
 	}
 	if ok := govalidator.IsByteLength(name, 4, 32); !ok {
-		return fmt.Errorf("username is not between 4 and 32 characters long")
+		return fmt.Errorf("name is not between 4 and 32 characters long")
 	}
 	return nil
 }
Fix typo in repository name validator errors
