KimNorgaard / validates_hostname

Extension to ActiveRecord::Base for validating hostnames and domain names
MIT License
38 stars 12 forks source link

Port source to C# #17

Closed ghost closed 2 years ago

ghost commented 2 years ago

Kim, I'm working an app that needs to track two similar but different data points. One is a Domain Name related to a Host, the other the Host Name itself. Both data points need validation and I really liked the approach used in this utility for going about the Host Name part, particularly the options that can be passed with a method call.

I'm a novice with GitHub so I wasn't sure how or if I even needed to get permissions for porting the logic in Ruby over to C#. And because I'm not Ruby developer, I might have some questions. I'll take an initial stab at conversion but if I have a question, would you be willing to provide some guidance on the original intent for some of these methods?

KimNorgaard commented 2 years ago

Sure, copy all you need. It's been a while since I made this so I might have some memory corruption going on that I'd need to deal with but just ask and I'll answer as best I can.

ghost commented 2 years ago

Sure, copy all you need. It's been a while since I made this so I might have some memory corruption going on that I'd need to deal with but just ask and I'll answer as best I can.

Thanks, converting was more straightforward than I expected, no problems there. And expanding on your original intent has worked out well. I've built my version around the idea of a rules engine that accepts a collection of rules to be applied to a Name. Each rule has an AppliedAs property so I can have multiple versions of each rule, one with an AplliedAs = Required, NotRequired, Allowed or NotAllowed. I did this for Hostnames, Domain names as well as Name Parts so that rules for each can be just a little bit different without having to create separate methods for each. Thx again.