I got it. In my setting
model:
before_save { self.main_host = main_host.gsub(/(http:|https:|www\.|:|\/)/,'').downcase if self.main_host }
validates_presence_of :main_host, if: lambda { self.use_subdomains }
validates :main_host, format: { with: VALID_HOST_REGEX }, allow_blank: true
Added allow_blank: true
to main_host
validation.