diff --git a/CHANGELOG.md b/CHANGELOG.md index 24ad3ec..487409a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Array schema generator now takes additional optional parameters `min` and `max` which a sugar for value length assertions. - Added schema generator for argument sinks. Takes `positional` and `named` as optional parameters that take schema types. Absence of one of these parameters indicate that these must also be absent from the argument type being validated. - **(Potentially Breaking)** Content now accepts `symbol` as a valid input type by default (see #20) +- **(Potentially Breaking)** If the tested value is `auto`, parsing no longer fails. If `default` is set, it takes the default value. If `optional` is set but not `default`, value is parsed as `none`. --- diff --git a/src/base-type.typ b/src/base-type.typ index 7eea03b..02bfa72 100644 --- a/src/base-type.typ +++ b/src/base-type.typ @@ -79,7 +79,7 @@ validate: (self, it, scope: (), ctx: z-ctx()) => { //it = self.default - if (it == none or type(it) == none) { + if (it == none or it == auto) { it = self.default } it = (self.pre-transform)(self, it) diff --git a/tests/types/string/ref/1.png b/tests/types/string/ref/1.png index ee98b62..1c54446 100644 Binary files a/tests/types/string/ref/1.png and b/tests/types/string/ref/1.png differ diff --git a/tests/types/string/test.typ b/tests/types/string/test.typ index 7840d94..7774c0d 100644 --- a/tests/types/string/test.typ +++ b/tests/types/string/test.typ @@ -47,4 +47,9 @@ #z.parse("192.168.0.1", z.ip()) == default -#z.parse(none, z.string(default: "Hello")) \ No newline at end of file +#let _ = z.parse(none, z.string(default: "Hello")) +#let _ = z.parse(auto, z.string(default: "Hello")) +#let _ = z.parse(auto, z.string(default: "Hello", optional: true)) +#let _ = repr(z.parse(auto, z.string(optional: true))) +// #z.parse(auto, z.string()) \ +#let _ = z.parse("none", z.string(default: "Hello")) \ No newline at end of file