Skip to content

Commit 2a8c754

Browse files
authored
Merge pull request #5 from ahmetsina/development
Removed manually added SwiftValidator files. SwiftValidatorNew pod added.
2 parents 329610b + a5047ed commit 2a8c754

104 files changed

Lines changed: 7281 additions & 537 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ALFormInput.podspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'ALFormInput'
11-
s.version = '0.1.0'
11+
s.version = '0.1.1'
1212
s.summary = 'Commonly used form inputs in our projects'
1313

1414
s.homepage = 'https://github.com/applogistdev/ALFormInput'
@@ -22,4 +22,5 @@ Pod::Spec.new do |s|
2222
s.frameworks = 'UIKit'
2323
s.dependency 'SkyFloatingLabelTextField', '~> 3.0'
2424
s.dependency 'PhoneNumberKit', '~> 3.1'
25+
s.dependency 'SwiftValidatorNew', '~> 4.2.0'
2526
end

ALFormInput/Classes/ALValidatableConfig.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// File.swift
2+
// ALValidatableConfig.swift
33
//
44
//
55
// Created by AppLogist on 10.04.2020.

ALFormInput/Classes/ALValidatableTextField.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
//
2+
// ALValidatableTextFieldT.swift
3+
// ALFormInput
4+
//
5+
// Created by AppLogist on 10.04.2020.
6+
// Copyright © 2020 AppLogist. All rights reserved.
7+
//
18

29
import UIKit
310
import SkyFloatingLabelTextField
411
import PhoneNumberKit
12+
import SwiftValidatorNew
513

614
public class ALValidatableTextField: SkyFloatingLabelTextField {
715

@@ -246,14 +254,14 @@ extension ALValidatableTextField: UITextFieldDelegate {
246254
extension ALValidatableTextField {
247255

248256
override open func textRect(forBounds bounds: CGRect) -> CGRect {
249-
paddingNeeded ? bounds.inset(by: padding ?? .zero) : super.textRect(forBounds: bounds)
257+
paddingNeeded ? bounds.insetBy(dx: padding?.top ?? 0, dy: padding?.bottom ?? 0) : super.textRect(forBounds: bounds)
250258
}
251259

252260
override open func placeholderRect(forBounds bounds: CGRect) -> CGRect {
253-
paddingNeeded ? bounds.inset(by: padding ?? .zero) : super.textRect(forBounds: bounds)
261+
paddingNeeded ? bounds.insetBy(dx: padding?.top ?? 0, dy: padding?.bottom ?? 0) : super.textRect(forBounds: bounds)
254262
}
255263

256264
override open func editingRect(forBounds bounds: CGRect) -> CGRect {
257-
paddingNeeded ? bounds.inset(by: padding ?? .zero) : super.textRect(forBounds: bounds)
265+
paddingNeeded ? bounds.insetBy(dx: padding?.top ?? 0, dy: padding?.bottom ?? 0) : super.textRect(forBounds: bounds)
258266
}
259267
}

ALFormInput/Classes/ALValidatableTextFieldType.swift

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
//
22
// ALValidatableTextFieldType.swift
3-
// ALTextFields
3+
// ALFormInput
44
//
55
// Created by AppLogist on 10.04.2020.
66
// Copyright © 2020 AppLogist. All rights reserved.
77
//
88

99
import UIKit
10+
import SwiftValidatorNew
1011

1112
public enum ALValidatableTextFieldType: String {
1213
case email = "Email"
@@ -21,25 +22,39 @@ public enum ALValidatableTextFieldType: String {
2122
case optional
2223

2324

25+
private var emailRule : EmailRule {
26+
EmailRule(message: "Geçersiz E-Posta Adresi")
27+
}
28+
29+
private var requiredRule: RequiredRule {
30+
RequiredRule(message: "Bu alan zorunludur")
31+
}
32+
33+
private func minLengthRule(_ length: Int) -> MinLengthRule {
34+
MinLengthRule(length: length, message: "En %ld karakter olmalıdır")
35+
}
36+
37+
private func exactLengthRule(_ length: Int) -> ExactLengthRule {
38+
ExactLengthRule(length: length, message: "%ld karakter olmalıdır")
39+
}
40+
2441
public var rules : [Rule] {
2542
switch self {
2643
case .email:
27-
return [RequiredRule(), EmailRule()]
44+
return [requiredRule, emailRule]
2845
case .password:
29-
return [RequiredRule(), PasswordRule()]
30-
case .name:
31-
return [RequiredRule(), MinLengthRule(length:3)]
32-
case .surname:
33-
return [RequiredRule(), MinLengthRule(length:3)]
46+
return [requiredRule, PasswordRule()]
47+
case .name, .surname:
48+
return [requiredRule, minLengthRule(3)]
3449
case .phoneNumber:
35-
return [RequiredRule(), CustomPhoneNumberRule()]
50+
return [requiredRule, CustomPhoneNumberRule()]
3651
case .creditCardNumber:
37-
return [RequiredRule(),
52+
return [requiredRule,
3853
CardNumberRule(),
3954
ReplacedExactLengthRule(length: 16, willRemoveString: " ")]
4055
case .tcIdentityNo:
41-
return [RequiredRule(),
42-
ExactLengthRule(length: 11),
56+
return [requiredRule,
57+
exactLengthRule(11),
4358
TCIdentityRule()]
4459
default:
4560
return []

ALFormInput/Classes/Extensions/AL+UITextField.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import UIKit
1010
private var __maxLengths = [UITextField: Int]()
11-
extension UITextField {
11+
public extension UITextField {
1212
@IBInspectable var maxLength: Int {
1313
get {
1414
guard let l = __maxLengths[self] else {

ALFormInput/Classes/ValidatorRules/CardExpiryMonthRule.swift

Lines changed: 0 additions & 50 deletions
This file was deleted.

ALFormInput/Classes/ValidatorRules/CardExpiryYearRule.swift

Lines changed: 0 additions & 59 deletions
This file was deleted.

ALFormInput/Classes/ValidatorRules/CardNumberRule.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright © 2020 AppLogist. All rights reserved.
77
//
88

9-
import Foundation
9+
import SwiftValidatorNew
1010
/**
1111
`CardNumberRule` is a subclass of Rule that defines how a credit card number is validated.
1212
*/

ALFormInput/Classes/ValidatorRules/CustomPhoneNumberRule.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
// Created by AppLogist on 13.04.2020.
66
// Copyright © 2020 AppLogist. All rights reserved.
77
//
8-
9-
import Foundation
108
import PhoneNumberKit
11-
9+
import SwiftValidatorNew
1210
public class CustomPhoneNumberRule: Rule {
1311

1412

ALFormInput/Classes/ValidatorRules/PhoneNumberRule.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
// Copyright (c) 2014 Byron Mackay. All rights reserved.
66
//
77

8-
import Foundation
9-
8+
import SwiftValidatorNew
109
/**
1110
`PhoneNumberRule` is a subclass of Rule that defines how a phone number is validated.
1211
*/

0 commit comments

Comments
 (0)