Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(string): impl variant validator and ensure backward compatibility #49

Merged
merged 2 commits into from
Jun 30, 2023

Conversation

josestg
Copy link
Member

@josestg josestg commented Jun 30, 2023

This feature basically provides a simple StringValidator for string variants (~string). In the current latest version, if we need a validator for the type VariantExample string, which is a string variant, we have to convert VariantExample to a string in order to use the StringValidator. These changes add a new API that reuses the StringValidator rules for string variants without any conversion.

Before:

type Variant string

const (
   VariantA Variant = "A"
   VariantB Variant = "B"
)

var validator = goval.String().In(string(VariantA), string(VariantB))

After:

type Variant string

const (
   VariantA Variant = "A"
   VariantB Variant = "B"
)

var validator = goval.StringVariant[Variant]().In(VariantA, VariantB)

@josestg josestg self-assigned this Jun 30, 2023
@codecov-commenter
Copy link

Codecov Report

Merging #49 (2fabefb) into develop (78cf99f) will increase coverage by 0.03%.
The diff coverage is 100.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@             Coverage Diff             @@
##           develop      #49      +/-   ##
===========================================
+ Coverage    91.77%   91.81%   +0.03%     
===========================================
  Files           13       13              
  Lines          462      464       +2     
===========================================
+ Hits           424      426       +2     
  Misses          29       29              
  Partials         9        9              
Impacted Files Coverage Δ
string.go 100.00% <100.00%> (ø)

@josestg josestg merged commit 7edf4e5 into develop Jun 30, 2023
7 checks passed
@josestg josestg deleted the feature/impl-string-variant-validators branch June 30, 2023 13:35
josestg added a commit that referenced this pull request Jun 30, 2023
* feat: add internal error wrapper

* feat(string): impl variant validator and ensure backward compatibility (#49)

* feat(string): impl variant validator and ensure backward compatibility

* refactor(string): use sort name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants