Skip to content

Commit 103f964

Browse files
authored
Implement Validator package (#1)
* Implement `ValidatorCore` * Integrate `GitHub Actions` * Implement `UIValidator` package - Remove `AnyValidationRule` - Get rid of support for older operating systems * Update `ci.yml` * Implenent a validation extension for `SwiftUI` views * Implement a validation `SwiftUI` extension * Implement `ValidationViewModifier` * Implement an extension for `ValidationModifier` * Implement a form validation logic * Implement validation rules * Update `README.md` * Update `README.md`
1 parent bbdc43d commit 103f964

48 files changed

Lines changed: 2415 additions & 1 deletion

Some content is hidden

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

.github/workflows/ci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: "validator"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
pull_request:
9+
paths:
10+
- '.swiftlint.yml'
11+
branches:
12+
- main
13+
- dev
14+
15+
concurrency:
16+
group: ci
17+
cancel-in-progress: true
18+
19+
jobs:
20+
SwiftLint:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v3
24+
- name: GitHub Action for SwiftLint
25+
uses: norio-nomura/action-swiftlint@3.2.1
26+
with:
27+
args: --strict
28+
env:
29+
DIFF_BASE: ${{ github.base_ref }}
30+
Latest:
31+
name: Test Latest (iOS, macOS, tvOS, watchOS)
32+
runs-on: macOS-12
33+
env:
34+
DEVELOPER_DIR: "/Applications/Xcode_14.1.app/Contents/Developer"
35+
timeout-minutes: 10
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
include:
40+
- destination: "OS=16.1,name=iPhone 14 Pro"
41+
name: "iOS"
42+
scheme: "Validator-Package"
43+
sdk: iphonesimulator
44+
- destination: "OS=16.1,name=Apple TV"
45+
name: "tvOS"
46+
scheme: "Validator-Package"
47+
sdk: appletvsimulator
48+
- destination: "OS=9.1,name=Apple Watch Series 8 (45mm)"
49+
name: "watchOS"
50+
scheme: "Validator-Package"
51+
sdk: watchsimulator
52+
- destination: "platform=macOS"
53+
name: "macOS"
54+
scheme: "Validator-Package"
55+
sdk: macosx
56+
steps:
57+
- uses: actions/checkout@v3
58+
- name: ${{ matrix.name }}
59+
run: xcodebuild test -scheme "${{ matrix.scheme }}" -destination "${{ matrix.destination }}" clean -enableCodeCoverage YES -resultBundlePath "./${{ matrix.sdk }}.xcresult" | xcpretty -r junit
60+
- name: Upload coverage reports to Codecov
61+
uses: codecov/codecov-action@v3.1.0
62+
with:
63+
token: ${{ secrets.CODECOV_TOKEN }}
64+
xcode: true
65+
xcode_archive_path: "./${{ matrix.sdk }}.xcresult"

.swiftformat

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Stream rules
2+
3+
--swiftversion 5.7
4+
5+
# Use 'swiftformat --options' to list all of the possible options
6+
7+
--header "\nValidator\nCopyright © {created.year} Space Code. All rights reserved.\n//"
8+
9+
--enable blankLinesBetweenScopes
10+
--enable blankLinesAtStartOfScope
11+
--enable blankLinesAtEndOfScope
12+
--enable blankLinesAroundMark
13+
--enable anyObjectProtocol
14+
--enable consecutiveBlankLines
15+
--enable consecutiveSpaces
16+
--enable duplicateImports
17+
--enable elseOnSameLine
18+
--enable emptyBraces
19+
--enable initCoderUnavailable
20+
--enable leadingDelimiters
21+
--enable numberFormatting
22+
--enable preferKeyPath
23+
--enable redundantBreak
24+
--enable redundantExtensionACL
25+
--enable redundantFileprivate
26+
--enable redundantGet
27+
--enable redundantInit
28+
--enable redundantLet
29+
--enable redundantLetError
30+
--enable redundantNilInit
31+
--enable redundantObjc
32+
--enable redundantParens
33+
--enable redundantPattern
34+
--enable redundantRawValues
35+
--enable redundantReturn
36+
--enable redundantSelf
37+
--enable redundantVoidReturnType
38+
--enable semicolons
39+
--enable sortedImports
40+
--enable sortedSwitchCases
41+
--enable spaceAroundBraces
42+
--enable spaceAroundBrackets
43+
--enable spaceAroundComments
44+
--enable spaceAroundGenerics
45+
--enable spaceAroundOperators
46+
--enable spaceInsideBraces
47+
--enable spaceInsideBrackets
48+
--enable spaceInsideComments
49+
--enable spaceInsideGenerics
50+
--enable spaceInsideParens
51+
--enable strongOutlets
52+
--enable strongifiedSelf
53+
--enable todos
54+
--enable trailingClosures
55+
--enable unusedArguments
56+
--enable void
57+
--enable markTypes
58+
--enable isEmpty
59+
60+
# format options
61+
62+
--wraparguments before-first
63+
--wrapcollections before-first
64+
--maxwidth 140

.swiftlint.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
excluded:
2+
- Tests
3+
- Package.swift
4+
- .build
5+
6+
# Rules
7+
8+
disabled_rules:
9+
- trailing_comma
10+
- todo
11+
- opening_brace
12+
13+
opt_in_rules: # some rules are only opt-in
14+
- anyobject_protocol
15+
- array_init
16+
- closure_body_length
17+
- closure_end_indentation
18+
- closure_spacing
19+
- collection_alignment
20+
- contains_over_filter_count
21+
- contains_over_filter_is_empty
22+
- contains_over_first_not_nil
23+
- contains_over_range_nil_comparison
24+
- convenience_type
25+
- discouraged_object_literal
26+
- discouraged_optional_boolean
27+
- empty_collection_literal
28+
- empty_count
29+
- empty_string
30+
- empty_xctest_method
31+
- enum_case_associated_values_count
32+
- explicit_init
33+
- fallthrough
34+
- fatal_error_message
35+
- file_name
36+
- file_types_order
37+
- first_where
38+
- flatmap_over_map_reduce
39+
- force_unwrapping
40+
- ibinspectable_in_extension
41+
- identical_operands
42+
- implicit_return
43+
- inert_defer
44+
- joined_default_parameter
45+
- last_where
46+
- legacy_multiple
47+
- legacy_random
48+
- literal_expression_end_indentation
49+
- lower_acl_than_parent
50+
- multiline_arguments
51+
- multiline_function_chains
52+
- multiline_literal_brackets
53+
- multiline_parameters
54+
- multiline_parameters_brackets
55+
- no_space_in_method_call
56+
- operator_usage_whitespace
57+
- optional_enum_case_matching
58+
- orphaned_doc_comment
59+
- overridden_super_call
60+
- override_in_extension
61+
- pattern_matching_keywords
62+
- prefer_self_type_over_type_of_self
63+
- prefer_zero_over_explicit_init
64+
- prefixed_toplevel_constant
65+
- private_action
66+
- prohibited_super_call
67+
- quick_discouraged_call
68+
- quick_discouraged_focused_test
69+
- quick_discouraged_pending_test
70+
- reduce_into
71+
- redundant_nil_coalescing
72+
- redundant_objc_attribute
73+
- redundant_type_annotation
74+
- required_enum_case
75+
- single_test_class
76+
- sorted_first_last
77+
- sorted_imports
78+
- static_operator
79+
- strict_fileprivate
80+
- switch_case_on_newline
81+
- toggle_bool
82+
- unavailable_function
83+
- unneeded_parentheses_in_closure_argument
84+
- unowned_variable_capture
85+
- untyped_error_in_catch
86+
- vertical_parameter_alignment_on_call
87+
- vertical_whitespace_closing_braces
88+
- vertical_whitespace_opening_braces
89+
- xct_specific_matcher
90+
- yoda_condition
91+
92+
force_cast: warning
93+
force_try: warning
94+
95+
identifier_name:
96+
excluded:
97+
- id
98+
- URL
99+
100+
analyzer_rules:
101+
- unused_import
102+
- unused_declaration
103+
104+
line_length:
105+
warning: 130
106+
error: 200
107+
108+
type_body_length:
109+
warning: 300
110+
error: 400
111+
112+
file_length:
113+
warning: 500
114+
error: 1200
115+
116+
function_body_length:
117+
warning: 30
118+
error: 50
119+
120+
large_tuple:
121+
error: 3
122+
123+
nesting:
124+
type_level:
125+
warning: 2
126+
statement_level:
127+
warning: 10
128+
129+
type_name:
130+
max_length:
131+
warning: 40
132+
error: 50

.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)