(name string)
| 528 | } |
| 529 | |
| 530 | func ValidateName(name string) error { |
| 531 | |
| 532 | validation := configs.GetValidationConfig() |
| 533 | |
| 534 | if len(name) < int(validation.NameSizeMin) || len(name) > int(validation.NameSizeMax) { |
| 535 | return fmt.Errorf("name must be between %d and %d characters long", validation.NameSizeMin, validation.NameSizeMax) |
| 536 | } |
| 537 | |
| 538 | if validation.NameRejectRegex != `` { |
| 539 | if !regexp.MustCompile(validation.NameRejectRegex.String()).MatchString(name) { |
| 540 | return errors.New(validation.NameRejectReason.String()) |
| 541 | } |
| 542 | } |
| 543 | |
| 544 | if bannedPattern, ok := configs.GetConfig().IsBannedName(name); ok { |
| 545 | return errors.New(`that username matched the prohibited name pattern: "` + bannedPattern + `"`) |
| 546 | } |
| 547 | |
| 548 | for _, mobName := range mobs.GetAllMobNames() { |
| 549 | if strings.EqualFold(mobName, name) { |
| 550 | return errors.New("that username is in use") |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | if Exists(name) { |
| 555 | return errors.New("that username is in use") |
| 556 | } |
| 557 | |
| 558 | return nil |
| 559 | } |
| 560 | |
| 561 | func ValidatePassword(pw string) error { |
| 562 |
no test coverage detected