You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This section documents the validation framework used by component constructors. The design is deterministic, non‑magical, and trait‑driven. The flow is:
4
12
5
13
```julia
@@ -10,15 +18,15 @@ The **typed cores** accept **numbers only**. All proxy handling happens in the *
* Rejects wrong arities and enforces presence using `required_fields(T)`.
20
-
* Maps optional keywords using `keyword_fields(T)`.
21
-
*For`has_radii(T) == true`, checks admissibility of raw radius inputs with `is_radius_input(T, x)`(numbers by default; types may extend to allow proxies).
27
+
* Rejects wrong arities: exactly `length(required_fields(T))` positionals are expected; optionals must be passed as keywords listed in `keyword_fields(T)`.
28
+
* Maps positionals to names using `required_fields(T)`; merges keyword arguments; rejects unknown keywords.
29
+
*If`has_radii(T) == true`, checks admissibility of raw radius inputs with `is_radius_input(T, Val(:radius_in), x)`and `is_radius_input(T, Val(:radius_ext), x)`. The default accepts only real, non‑complex numbers; types may extend to allow proxies.
22
30
* Returns a **raw**`NamedTuple`.
23
31
24
32
***`parse(::Type{T}, nt)`**
@@ -34,38 +42,38 @@ The **typed cores** accept **numbers only**. All proxy handling happens in the *
34
42
35
43
***`validate!(::Type{T}, args...; kwargs...)`**
36
44
37
-
* Orchestrates the pipeline.
38
-
* Converts `Base.Pairs` → `NamedTuple` once; do not pass `Pairs` to user extensions.
45
+
* Orchestrates the pipeline. Use this in all convenience constructors.
39
46
40
-
### 1.2 Traits (configuration surface)
47
+
### Traits (configuration surface)
41
48
42
49
*`has_radii(::Type{T})::Bool` — enables the radii rule bundle and raw acceptance checks.
43
50
*`has_temperature(::Type{T})::Bool` — enables finiteness check on `:temperature`.
*`IsA{Material}` enforces the material argument type.
142
-
143
150
**Parsing**:
144
151
145
152
```julia
146
153
Validation.parse(::Type{Tubular}, nt) =begin
147
154
rin, rex =_normalize_radii(Tubular, nt.radius_in, nt.radius_ext)
148
-
(; nt..., radius_in=rin, radius_ext=rex)
155
+
(; nt..., radius_in=rin, radius_ext=rex)
149
156
end
150
157
```
151
158
152
-
Rationale: centralizes radius proxy resolution and uncertainty semantics in one place. The output is numeric radii. After this step, the `Normalized` rules guarantee that rule checks run on numbers.
153
-
154
159
**Convenience constructor**:
155
160
156
161
```julia
157
-
functionTubular(radius_in, radius_ext, material_props; temperature = _DEFS_TUBULAR[1])
Rationale: forces all user entry through `validate!`, then hands a coherent, type‑promoted set of values to the numeric core.
165
+
This expands to a weakly‑typed method that calls `validate!`, promotes using `_promotion_T`, coerces via `_coerced_args`, and delegates to the numeric core.
166
166
167
167
**Failure modes intentionally trapped**:
168
168
@@ -173,98 +173,98 @@ Rationale: forces all user entry through `validate!`, then hands a coherent, typ
173
173
174
174
---
175
175
176
-
## 4. Template for a New Component
177
-
178
-
Use the following checklist as a copy/paste starting point. Replace `NewPart` and fields accordingly.
176
+
## Template for a new component
179
177
180
178
```julia
181
179
# 1) Numeric core (numbers only)
182
180
functionNewPart(a::T, b::T, material::Material{T}, temperature::T) where {T<:REALSCALAR}
183
-
# compute derived quantities, then construct
181
+
# compute derived, then construct
184
182
end
185
183
186
184
# 2) Trait config
187
-
Validation.has_radii(::Type{NewPart}) =true# if the type has radii
188
-
Validation.has_temperature(::Type{NewPart}) =true# if temperature is used
Order = [:module, :constant, :type, :function, :macro]
260
+
Public = true
261
+
Private = true
262
+
```
267
263
268
264
---
269
265
270
-
This framework is designed to be extended in small, explicit increments. If behavior changes, change the trait and the minimal corresponding code; the rest of the pipeline remains stable.
266
+
## Index
267
+
```@index
268
+
Pages = ["validation.md"]
269
+
Order = [:module, :constant, :type, :function, :macro]
0 commit comments