lib/cocina/models/validators/date_time_validator.rb in cocina-models-0.96.0 vs lib/cocina/models/validators/date_time_validator.rb in cocina-models-0.98.0
- old
+ new
@@ -1,10 +1,9 @@
# frozen_string_literal: true
require 'edtf'
require 'jsonpath'
-require 'rss'
module Cocina
module Models
module Validators
# Validates that dates of known types are type-valid
@@ -85,21 +84,10 @@
rescue StandardError
false
end
def valid_w3cdtf?(value)
- Time.w3cdtf(value)
- true
- rescue StandardError
- # NOTE: the upstream W3CDTF implementation in the `rss` gem does not
- # allow two patterns that should be valid per the specification:
- #
- # * YYYY
- # * YYYY-MM
- #
- # This catches the false positives from the upstream gem and allow
- # these two patterns to validate
- /\A\d{4}(-0[1-9]|-1[0-2])?\Z/.match?(value)
+ W3cdtfValidator.validate(value)
end
def druid
@druid ||= attributes[:externalIdentifier]
end