Skip to content

Commit 26fc637

Browse files
committed
Merge branch 'main' into development
2 parents 36f9f1c + 80e63c3 commit 26fc637

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

ValueTransformers.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
05233032243CD25B005BBB8E /* ValueTransformers.h in Headers */ = {isa = PBXBuildFile; fileRef = 05233031243CD25B005BBB8E /* ValueTransformers.h */; settings = {ATTRIBUTES = (Public, ); }; };
1111
05233035243CD294005BBB8E /* PerformSelectorUnsafe.h in Headers */ = {isa = PBXBuildFile; fileRef = 05233033243CD294005BBB8E /* PerformSelectorUnsafe.h */; settings = {ATTRIBUTES = (Public, ); }; };
1212
05233036243CD294005BBB8E /* PerformSelectorUnsafe.m in Sources */ = {isa = PBXBuildFile; fileRef = 05233034243CD294005BBB8E /* PerformSelectorUnsafe.m */; };
13+
058AC6302BA9E1AD001EEB04 /* SingleLineString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 058AC62F2BA9E1AD001EEB04 /* SingleLineString.swift */; };
1314
05D3735E20ED91E5007FE14A /* StringIsNotEmpty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05D3734320ED91E5007FE14A /* StringIsNotEmpty.swift */; };
1415
05D3735F20ED91E5007FE14A /* ArrayIsEmpty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05D3734420ED91E5007FE14A /* ArrayIsEmpty.swift */; };
1516
05D3736020ED91E5007FE14A /* StringIsEmpty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05D3734520ED91E5007FE14A /* StringIsEmpty.swift */; };
@@ -85,6 +86,7 @@
8586
05233031243CD25B005BBB8E /* ValueTransformers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ValueTransformers.h; sourceTree = "<group>"; };
8687
05233033243CD294005BBB8E /* PerformSelectorUnsafe.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PerformSelectorUnsafe.h; sourceTree = "<group>"; };
8788
05233034243CD294005BBB8E /* PerformSelectorUnsafe.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PerformSelectorUnsafe.m; sourceTree = "<group>"; };
89+
058AC62F2BA9E1AD001EEB04 /* SingleLineString.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SingleLineString.swift; sourceTree = "<group>"; };
8890
05A6D085238BF1700032EA48 /* Debug - Library.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Debug - Library.xcconfig"; sourceTree = "<group>"; };
8991
05A6D086238BF1700032EA48 /* Release - Library.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Release - Library.xcconfig"; sourceTree = "<group>"; };
9092
05CD4AB220ED7B2200DBDE99 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
@@ -273,6 +275,7 @@
273275
05233034243CD294005BBB8E /* PerformSelectorUnsafe.m */,
274276
EF0F53582715DB6100BE981A /* SetIsEmpty.swift */,
275277
EF0F535A2715DD1900BE981A /* SetIsNotEmpty.swift */,
278+
058AC62F2BA9E1AD001EEB04 /* SingleLineString.swift */,
276279
05D3734520ED91E5007FE14A /* StringIsEmpty.swift */,
277280
05D3734320ED91E5007FE14A /* StringIsNotEmpty.swift */,
278281
05D3734E20ED91E5007FE14A /* UppercaseString.swift */,
@@ -430,6 +433,7 @@
430433
05D3736920ED91E5007FE14A /* UppercaseString.swift in Sources */,
431434
05D3736620ED91E5007FE14A /* BoolToDisabledTextColor.swift in Sources */,
432435
05233036243CD294005BBB8E /* PerformSelectorUnsafe.m in Sources */,
436+
058AC6302BA9E1AD001EEB04 /* SingleLineString.swift in Sources */,
433437
05D3735E20ED91E5007FE14A /* StringIsNotEmpty.swift in Sources */,
434438
05D3736720ED91E5007FE14A /* ArrayIsNotEmpty.swift in Sources */,
435439
05D3736220ED91E5007FE14A /* NumberIsGreaterThanZero.swift in Sources */,
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*******************************************************************************
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2022, Jean-David Gadina - www.xs-labs.com
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the Software), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
******************************************************************************/
24+
25+
import Foundation
26+
27+
@objc( VTSingleLineString )
28+
public class SingleLineString: ValueTransformer
29+
{
30+
@objc
31+
public override class func transformedValueClass() -> AnyClass
32+
{
33+
return NSString.self
34+
}
35+
36+
@objc
37+
public override class func allowsReverseTransformation() -> Bool
38+
{
39+
return false
40+
}
41+
42+
@objc
43+
public override func transformedValue( _ value: Any? ) -> Any?
44+
{
45+
( value as? String )?.components( separatedBy: .newlines ).first
46+
}
47+
}

ValueTransformersTests/ValueTransformersTests.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,4 +301,19 @@ - ( void )testVTSetIsNotEmpty
301301
XCTAssertTrue( ( ( NSNumber * )[ vt transformedValue: [ NSSet setWithArray: @[ @"" ] ] ] ).boolValue, @"" );
302302
}
303303

304+
- ( void )testSingleLineString
305+
{
306+
VTSingleLineString * vt;
307+
308+
vt = [ VTSingleLineString new ];
309+
310+
XCTAssertEqual( [ VTSingleLineString transformedValueClass ], [ NSString class ], @"" );
311+
XCTAssertFalse( [ VTSingleLineString allowsReverseTransformation ], @"" );
312+
313+
XCTAssertEqualObjects( [ vt transformedValue: nil ], nil, @"" );
314+
XCTAssertEqualObjects( [ vt transformedValue: @0 ], nil, @"" );
315+
XCTAssertEqualObjects( [ vt transformedValue: @"hello, world" ], @"hello, world", @"" );
316+
XCTAssertEqualObjects( [ vt transformedValue: @"hello, world\nhello, universe" ], @"hello, world", @"" );
317+
}
318+
304319
@end

0 commit comments

Comments
 (0)