github.com/go-email-validator/go-email-validator@v0.0.0-20230409163946-b8b9e6a0552e/pkg/presentation/check-if-email-exist/role.go (about)

     1  package checkifemailexist
     2  
     3  import (
     4  	"github.com/go-email-validator/go-email-validator/pkg/ev"
     5  	"github.com/go-email-validator/go-email-validator/pkg/ev/evmail"
     6  	"github.com/go-email-validator/go-email-validator/pkg/presentation/converter"
     7  )
     8  
     9  type rolePresentation struct {
    10  	IsRoleAccount bool `json:"is_role_account"`
    11  }
    12  
    13  type roleConverter struct{}
    14  
    15  func (roleConverter) Can(_ evmail.Address, result ev.ValidationResult, _ converter.Options) bool {
    16  	return result.ValidatorName() == ev.RoleValidatorName
    17  }
    18  
    19  func (roleConverter) Convert(_ evmail.Address, result ev.ValidationResult, _ converter.Options) interface{} {
    20  	return rolePresentation{!result.IsValid()}
    21  }