Direct immutable Ion value validation against Smithy shapes
///|
test {
let loaded = @smithy.Loader::new()
.add_idl(
"model.smithy", "$version: \"2\"\nnamespace example\nstructure Input { @required name: String }",
)
.assemble()
let prepared = @adapter.PreparedValidator::prepare(
loaded.model.unwrap(),
@smithy.ShapeId::parse("example#Input").unwrap(),
)
let value = @ion.Ion::from_fields([
@ion.Field("name", @ion.Ion::string("Ada")),
])
assert_true(prepared.validate(value).is_valid())
}| Ion value | Smithy mapping |
|---|---|
| bool, string | Boolean, String and matching string enums; normal constraints apply |
| int | Exact numeric token; numeric targets apply their bounds and range |
| decimal | BigDecimal, Float or Double; coefficient, exponent and signed zero stay exact |
| float | Float or Double; exact binary numeric magnitude and range checks |
| timestamp | Timestamp with valid calendar, seconds precision and known offset |
| blob | Blob with byte length constraints |
| list, struct | List, structure, map, union or Document as appropriate |
| null and typed null | Document or sparse collection positions; never an absent member |
| symbol, clob, sexp | UnsupportedValue |
| annotated value | UnsupportedValue, with descendants still inspected at their original paths |
pub(all) struct Finding {
code : FindingCode
severity : FindingSeverity
path : InstancePath
shape : ShapeId
message : String
native_kind : IonType?
} derive(Eq, Debug)pub struct PreparedValidator {
// private fields
}fn PreparedValidator::prepare(model : Model, shape : ShapeId, config? : Config) -> PreparedValidator raise PreparationErrorimpl ToJson for ValidationResult