feat: Initial commit
This commit is contained in:
24
Sources/ManualS/Internal/RequiredKW.swift
Normal file
24
Sources/ManualS/Internal/RequiredKW.swift
Normal file
@@ -0,0 +1,24 @@
|
||||
import Models
|
||||
import Validations
|
||||
|
||||
extension RequiredKW.Request {
|
||||
func respond() async throws -> RequiredKW.Response {
|
||||
try await validate()
|
||||
let capacityAtDesign = self.capacityAtDesign ?? 0
|
||||
let requiredKW = (Double(heatLoss) - Double(capacityAtDesign)) / 3413
|
||||
return .init(requiredKW: requiredKW)
|
||||
}
|
||||
}
|
||||
|
||||
extension RequiredKW.Request: AsyncValidatable {
|
||||
|
||||
@inlinable
|
||||
public var body: some AsyncValidation<Self> {
|
||||
AsyncValidator.accumulating {
|
||||
AsyncValidator.greaterThan(\.heatLoss, 0)
|
||||
AsyncValidator.validate(\.capacityAtDesign) {
|
||||
AsyncValidator.greaterThan(0).optional()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user