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

Add DNS RFC 1035 label format validator #833

Merged
merged 3 commits into from
Jan 2, 2022
Merged

Add DNS RFC 1035 label format validator #833

merged 3 commits into from
Jan 2, 2022

Conversation

0n1shi
Copy link
Contributor

@0n1shi 0n1shi commented Sep 16, 2021

Enhances

Make sure that you've checked the boxes below before you submit PR:

  • Tests exist or have been written that cover this particular change.

Change details:

  • Add DNS RFC 1035 label validation based on RFC 1035

@go-playground/validator-maintainers

Sorry, something went wrong.

@coveralls
Copy link

coveralls commented Sep 16, 2021

Coverage Status

Coverage increased (+0.008%) to 75.12% when pulling 6538fbe on 0n1shi:dns_rfc1035 into c67d01d on go-playground:master.

jeffwidman
jeffwidman previously approved these changes Oct 26, 2021
Copy link

@jeffwidman jeffwidman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me other than a few small things.

@deankarn any objections to merging once review items are addressed?

{"abc-", "dns_rfc1035_label", false},
{"abc-123", "dns_rfc1035_label", true},
{"ABC", "dns_rfc1035_label", false},
{"ABC-123", "dns_rfc1035_label", false},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that input may come from someone who has no idea what they're doing, what about some more obtuse edge cases like:

  • "abc-abc"
  • "ABC-ABC"
  • "123-abc"
  • ""
    ?

validate := New()

for i, test := range tests {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove this blank line? Blank lines are good to denote section breaks for improved readability, but here IMO it just makes it so less LOC fit on a single screen, which actually reduces readability. So just maybe be not quite so quick to insert one.

baked_in.go Outdated
// isDnsRFC1035LabelFormat is the validation function for validating if the current field's value is a valid dns RFC 1035 label, defined in RFC 1035
func isDnsRFC1035LabelFormat(fl FieldLevel) bool {
val := fl.Field().String()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove blank line?

baked_in.go Outdated
@@ -2407,3 +2408,10 @@ func isIsoBicFormat(fl FieldLevel) bool {

return bicRegex.MatchString(bicString)
}

// isDnsRFC1035LabelFormat is the validation function for validating if the current field's value is a valid dns RFC 1035 label, defined in RFC 1035

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Break this comment into mulitple lines and end with a period?

No need for it to keep going and going to the right...

@0n1shi
Copy link
Contributor Author

0n1shi commented Oct 27, 2021

@jeffwidman
Thank you for your review.
I fixed these above.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@deankarn deankarn merged commit ec2071b into go-playground:master Jan 2, 2022
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

4 participants