Skip to content

Instantly share code, notes, and snippets.

@Cee
Created November 23, 2016 06:52
Show Gist options
  • Save Cee/b0c7188ad868f5a249722a12a0563aa5 to your computer and use it in GitHub Desktop.
Save Cee/b0c7188ad868f5a249722a12a0563aa5 to your computer and use it in GitHub Desktop.
Value Transformer
class IsNotEmpty: ValueTransformer {
override class func transformedValueClass() -> Swift.AnyClass {
return Int.self as! AnyClass
}
override class func allowsReverseTransformation() -> Bool {
return false
}
override func transformedValue(_ value: Any?) -> Any? {
guard let value = value as? Int else {
return false
}
return value > 0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment