get_errors? fixed

This commit is contained in:
Philippe Pittoli 2023-05-07 05:06:15 +02:00
parent ad83a34437
commit a7c2096423

View File

@ -259,7 +259,7 @@ class DNSManager::Storage::Zone
io << "TEST" io << "TEST"
end end
def get_errors? : Array(Error) def get_errors? : Array(Error)?
errors = [] of Error errors = [] of Error
unless Zone.is_domain_valid? @domain unless Zone.is_domain_valid? @domain
errors << "invalid domain #{@domain}" errors << "invalid domain #{@domain}"
@ -280,8 +280,12 @@ class DNSManager::Storage::Zone
errors << "invalid zone: no NS record" errors << "invalid zone: no NS record"
end end
if errors.empty?
nil
else
errors errors
end end
end
# This regex only is "good enough for now". # This regex only is "good enough for now".
def self.is_domain_valid?(domain) : Bool def self.is_domain_valid?(domain) : Bool