Description
A closure and protocol based framework for ValueTransformer, helpful functions to register ValueTransformer by identifier.
ValueTransformerKit alternatives and similar libraries
Based on the "Kit" category.
Alternatively, view ValueTransformerKit alternatives based on common mentions on social networks and blogs.
-
C4iOS
C4 is an open-source creative coding framework that harnesses the power of native iOS programming with a simplified API that gets you working with media right away. Build artworks, design interfaces and explore new possibilities working with media and interaction. -
BFKit-Swift
BFKit-Swift is a collection of useful classes, structs and extensions to develop Apps faster.
CodeRabbit: AI Code Reviews for Developers

* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of ValueTransformerKit or a related project?
README
ValueTransformerKit
A closure and protocol based framework for ValueTransformer
, helpful functions to register ValueTransformer
by identifier.
Create a ValueTransformer
Using closures
let transformer = ValueTransformer.closure { object in
return ...
}
A ValueTransformer
subclass is no more necessary using this method.
Using protocol implementation
Implement ValueTransformerType
or ResersableValueTransformerType
and an a computed property transformer
will be accessible.
Using enum
Define your enum
, a list of all your enum case in transformers
, implement the function transformedValue
of ValueTransformerType
protocol
enum StringTransformers: String, ValueTransformers, ValueTransformerType {
case capitalized, lowercased, uppercased
public static let transformers: [StringTransformers] = [.capitalized, .lowercased, .uppercased]
public func transformedValue(_ value: Any?) -> Any? { ../* string manipulation */ }
}
Register it
You can retrieve a value transformer using optional initializer of ValueTransformer
: init?(forName: NSValueTransformerName)
A protocol ValueTransformerRegisterable
help you to register your ValueTransformer
By providing a value transformer and an identifier name
, a new method will be available
myValueTransformer.register()
So just defined an identifier name
in your ValueTransformerType
struct MyTransformer: ValueTransformerType, ValueTransformerRegisterable {
var name = NSValueTransformerName(rawValue: "MyTransformation")
For a singleton instance
You can define a singleton instance using ValueTransformerSingleton
struct MyTransformer: ValueTransformerType, ValueTransformerRegisterable, ValueTransformerSingleton {
var name = NSValueTransformerName(rawValue: "MyTransformation")
public static let instance = MyTransformer()
or a static function will help you to register it
MyTransformer.register() // same as MyTransformer.instance.register()
For the previous enum example
enum StringTransformers: String, ValueTransformers, ValueTransformerType {
...
var name: NSValueTransformerName {
return NSValueTransformerName("String" + self.rawValue.capitalized)
}
then you can register one by one
StringTransformers.capitalized.register()
or all case
StringTransformers.register()
Some implementations
String
- capitalized
- uppercased
- lowercased
Image
- PNG Representation
- JPEG Representation
Date and Time
- RFC 2822 Timestamp*
- Using
DateFormatter.Style
Number
- Using
NumberFormatter.Style
Locale component
- Using
NSLocale.Key
Check if empty or not
- Using
IsEmpty
(resp.IsNotEmpty
) you could transformString
,NSString
,Array
,NSArray
,Dictionnary
, etc... to boolean.true
(resp.false
) if empty
Apple Doc
License
ValueTransformerKit is available under the MIT license. See the LICENSE file for more info.
<!-- MARKDOWN LINKS & IMAGES --> <!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
*Note that all licence references and agreements mentioned in the ValueTransformerKit README section above
are relevant to that project's source code only.