Skip to content

Commit d47f52b

Browse files
committed
adding some docstrings
1 parent 0eef3a0 commit d47f52b

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

internal/pkg/options/email_address_validator.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ type EmailAddressValidator struct {
1818
AllowedEmails []string
1919
}
2020

21+
// NewEmailAddressValidator takes in a list of email addresses and returns a Validator object.
22+
// The validator can be used to validate that the session.Email:
23+
// - is non-empty
24+
// - matches one of the originally passed in email addresses
25+
// (case insensitive)
26+
// - if the originally passed in list of emails consists only of "*", then all emails
27+
// are considered valid based on their domain.
28+
// If valid, nil is returned in place of an error.
2129
func NewEmailAddressValidator(allowedEmails []string) EmailAddressValidator {
2230
var emailAddresses []string
2331

internal/pkg/options/email_domain_validator.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ type EmailDomainValidator struct {
1616
AllowedDomains []string
1717
}
1818

19+
// NewEmailDomainValidator takes in a list of domains and returns a Validator object.
20+
// The validator can be used to validate that the session.Email:
21+
// - is non-empty
22+
// - the domain of the email address matches one of the originally passed in domains.
23+
// (case insensitive)
24+
// - if the originally passed in list of domains consists only of "*", then all emails
25+
// are considered valid based on their domain.
26+
// If valid, nil is returned in place of an error.
1927
func NewEmailDomainValidator(allowedDomains []string) *EmailDomainValidator {
2028
emailDomains := make([]string, 0, len(allowedDomains))
2129

internal/pkg/options/email_group_validator.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ type EmailGroupValidator struct {
1818
AllowedGroups []string
1919
}
2020

21+
// NewEmailGroupValidator takes in a Provider object and a list of groups, and returns a Validator object.
22+
// The validator can be used to validate that the session.Email:
23+
// - if an empty list is passed in in place of a list of groups, all session.Emails will be considered valid
24+
// regardless of group membership with that particular Provider.
25+
// - according to the Provider that was passed in, is a member of one of the originally passed in groups.
26+
// If valid, nil is returned in place of an error.
2127
func NewEmailGroupValidator(provider providers.Provider, allowedGroups []string) EmailGroupValidator {
2228
return EmailGroupValidator{
2329
Provider: provider,

0 commit comments

Comments
 (0)