package validators import ( "fmt" ) func McVersion(versions []string) TextInputValidator { return TextInputMCVersion{ versions: versions, } } type TextInputMCVersion struct { versions []string } func (d TextInputMCVersion) Notice() string { var versionString string for index, version := range d.versions { if index == (len(d.versions) - 1) { versionString = versionString + version } else { versionString = versionString + version + ", " } } return fmt.Sprintf("Available Versions: %s", versionString) } func (d TextInputMCVersion) ValidationFunc(input string) bool { isFound := false for _, ver := range d.versions { if ver == input { isFound = true break } } return isFound }