Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

Commit

Permalink
docs: add docs to methods and types
Browse files Browse the repository at this point in the history
  • Loading branch information
brandaogabriel7 committed Dec 19, 2022
1 parent 4a10f29 commit 3a0ff3b
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/factories/password_validation_service_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"github.com/brandaogabriel7/studio-sol-back-end-test/src/strategies/validation"
)

// Creates the a PasswordValidation service with the following rule validation strategies:
// minSize, minSpecialChars, minDigit, noRepeted
func GetDefaultPasswordValidationService() password_validation.PasswordValidationService {
validationStrategies := map[string]validation.ValidationStrategy{
string(validation.MIN_SIZE): validation.MinSizeValidationStrategy{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/brandaogabriel7/studio-sol-back-end-test/src/strategies/validation"
)

// Checks if the password is valid based on a set of rules.
type PasswordValidationService struct {
strategies map[string]validation.ValidationStrategy
}
Expand Down
1 change: 1 addition & 0 deletions src/strategies/validation/min_digit.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package validation

import "regexp"

// Checks that the password contains at least the minimum number of digits.
type MinDigitValidationStrategy struct {
digitRegexp regexp.Regexp
}
Expand Down
1 change: 1 addition & 0 deletions src/strategies/validation/min_size.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package validation

// Checks that the password is at least the minimum size.
type MinSizeValidationStrategy struct {}

func (md MinSizeValidationStrategy) IsValid(password string, value int) bool {
Expand Down
2 changes: 2 additions & 0 deletions src/strategies/validation/min_special_chars.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package validation

import "regexp"

// Checks that the password contains at least the minimum number of special chars.
// The special chars are these: !@#$%^&*()-+\/{}[]
type MinSpecialCharsStrategy struct {
specialCharsRegexp regexp.Regexp
}
Expand Down
1 change: 1 addition & 0 deletions src/strategies/validation/no_repeted.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package validation

import "strings"

// Checks that there are no consecutive repeated characters in the given password.
type NoRepetedStrategy struct {}

func (nr NoRepetedStrategy) IsValid(password string, _ int) bool {
Expand Down
1 change: 1 addition & 0 deletions src/strategies/validation/validation_strategy.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package validation

// ValidationStrategy defines a strategy to validate passwords based on a rule.
type ValidationStrategy interface {
IsValid(password string, value int) bool
}
1 change: 1 addition & 0 deletions src/strategies/validation/validation_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package validation

// ValidationType defines a password validation rule type.
type ValidationType string

const MIN_SIZE ValidationType = "minSize"
Expand Down
1 change: 1 addition & 0 deletions src/utils/slice_utils.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package utils

// Contains checks if a slice contains the specified string.
func Contains(s []string, str string) bool {
for _, v := range s {
if v == str {
Expand Down

0 comments on commit 3a0ff3b

Please sign in to comment.