Class: DnsMadeEasy::CLI::Commands::Zone::Validate

Inherits:
Base
  • Object
show all
Defined in:
lib/dnsmadeeasy/cli/commands/zone.rb

Overview

Validates a standard DNS zone file.

Constant Summary

Constants inherited from Base

Base::DEFAULT_CREDENTIAL_PATHS, Base::SUPPORTED_FORMATS

Constants included from MessageHelpers

MessageHelpers::BOX_OPTIONS, MessageHelpers::KEY_WIDTH

Instance Method Summary collapse

Methods included from MessageHelpers

error, included, info, kv, print_box, success, warn

Instance Method Details

#call(file:) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/dnsmadeeasy/cli/commands/zone.rb', line 69

def call(file:, **)
  result = DnsMadeEasy::Zone::Parser.new(::File.read(file)).call

  if result.success?
    record_count = result.value!.records.length
    success("Zone file is valid.\n#{kv('Records', record_count)}")
  else
    warning("Zone file is invalid.\n#{result.failure.join("\n")}")
    raise ReportedError, 'zone file is invalid'
  end
end