Skip to content

Commit 4bf74c2

Browse files
committed
Allow dates to have numeric default
1 parent 060f0d0 commit 4bf74c2

File tree

3 files changed

+10
-54
lines changed

3 files changed

+10
-54
lines changed

.swiftformat

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

Sources/SotoSmithy/Selectors/BasicSelectors.swift

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,55 +16,34 @@
1616
public struct TypeSelector<S: Shape>: Selector {
1717
public init() {}
1818
public func select(using model: Model, shape: Shape) -> Bool {
19-
return type(of: shape) == S.self
19+
type(of: shape) == S.self
2020
}
2121
}
2222

2323
/// Return true is shape is a number type
2424
public struct NumberSelector: Selector {
2525
public init() {}
2626
public func select(using model: Model, shape: Shape) -> Bool {
27-
return
28-
shape is ByteShape ||
29-
shape is ShortShape ||
30-
shape is IntegerShape ||
31-
shape is LongShape ||
32-
shape is FloatShape ||
33-
shape is DoubleShape ||
34-
shape is BigDecimalShape ||
35-
shape is BigIntegerShape ||
36-
shape is IntEnumShape
27+
shape is ByteShape || shape is ShortShape || shape is IntegerShape || shape is LongShape || shape is FloatShape || shape is DoubleShape
28+
|| shape is BigDecimalShape || shape is BigIntegerShape || shape is IntEnumShape
3729
}
3830
}
3931

4032
/// Return true if shape is a simple type
4133
public struct SimpleTypeSelector: Selector {
4234
public init() {}
4335
public func select(using model: Model, shape: Shape) -> Bool {
44-
return
45-
shape is BlobShape ||
46-
shape is StringShape ||
47-
shape is BooleanShape ||
48-
shape is ByteShape ||
49-
shape is ShortShape ||
50-
shape is IntegerShape ||
51-
shape is LongShape ||
52-
shape is FloatShape ||
53-
shape is DoubleShape ||
54-
shape is BigDecimalShape ||
55-
shape is BigIntegerShape ||
56-
shape is TimestampShape ||
57-
shape is IntEnumShape ||
58-
shape is EnumShape ||
59-
shape is DocumentShape
36+
shape is BlobShape || shape is StringShape || shape is BooleanShape || shape is ByteShape || shape is ShortShape || shape is IntegerShape
37+
|| shape is LongShape || shape is FloatShape || shape is DoubleShape || shape is BigDecimalShape || shape is BigIntegerShape
38+
|| shape is TimestampShape || shape is IntEnumShape || shape is EnumShape || shape is DocumentShape
6039
}
6140
}
6241

6342
/// Return true if shape is either a list or a set
6443
public struct CollectionSelector: Selector {
6544
public init() {}
6645
public func select(using model: Model, shape: Shape) -> Bool {
67-
return shape is ListShape
46+
shape is ListShape
6847
}
6948
}
7049

@@ -103,7 +82,7 @@ public struct OrTargetSelector: Selector {
10382
public struct TraitSelector<T: StaticTrait>: Selector {
10483
public init() {}
10584
public func select(using model: Model, shape: Shape) -> Bool {
106-
return shape.trait(type: T.self) != nil
85+
shape.trait(type: T.self) != nil
10786
}
10887
}
10988

@@ -116,6 +95,6 @@ public struct TraitNameSelector: Selector {
11695
}
11796

11897
public func select(using model: Model, shape: Shape) -> Bool {
119-
return shape.trait(named: self.name) != nil
98+
shape.trait(named: self.name) != nil
12099
}
121100
}

Sources/SotoSmithy/Traits/Types/TypeRefinementTraits.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public struct DefaultTrait: OptionalSingleValueTrait {
134134
}
135135
case .number(let n):
136136
let selector = NumberSelector()
137-
guard selector.select(using: model, shape: targetShape) else {
137+
guard selector.select(using: model, shape: targetShape) || targetShape is TimestampShape else {
138138
throw Smithy.ValidationError(reason: "Invalid default value \(n) for **")
139139
}
140140
case .string(let s):

0 commit comments

Comments
 (0)