import Foundation extension Date: StringProperty { private static let metadataDate: DateFormatter = { let df = DateFormatter() df.dateFormat = "dd.MM.yy" return df }() init?(_ value: String) { guard let date = Date.metadataDate.date(from: value) else { return nil } self = date } static var castFailureReason: String { "Date string format must be 'dd.MM.yy'" } } extension Date: DefaultValueProvider { static var defaultValue: Date { .init() } }