The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
is_type(value, type): returns
TRUE/FALSE and never throws for invalid
data.parse_as(value, type): returns the parsed value or
throws.safe_parse(value, type): returns a
sicher_parse_result with success,
data, issues (a data frame with
path, message, expected,
got and code) and error.validate_json(json, type): parses JSON with
jsonlite and checks the result in one step (safe = TRUE
returns a safe_parse() result).to_json_schema(type): exports a type as a JSON
Schema (draft 2020-12) list, or as a JSON string with
json = TRUE.todos[[2]]$title or users$id.
ListOf() errors now say which element failed.Type error in 'person$age': Missing required field (expected numeric).sicher_type_error with an issues element, so
they can be caught with
tryCatch(..., sicher_type_error = function(e) e$issues).Factor
instead of Factor()) now gives a hint.Tuple(...): fixed-length lists with a type per
position.Record(keys, values): named lists or named vectors with
arbitrary keys (Record<K, V>,
z.record()).DiscriminatedUnion(key, ...): tagged unions where the
key field picks the member to check, so errors point at the
right fields (z.discriminatedUnion()).Lazy(fn): recursive types such as trees
(z.lazy()).InstanceOf(class): objects inheriting from an S3, S4 or
R6 class (z.instanceof()).Brand(type, brand) and brand(value, type):
nominal types, so a UserId cannot be used where an
OrderId is expected.FunctionOf(params, .return): function signatures.
Checked functions are wrapped with typed_function(), so
their later calls are checked too.Factor(levels), Date,
DateTime, Environment and
MatrixOf(type, nrow, ncol) for common R objects.
MatrixOf is named so it does not clash with the Matrix
package.Positive, NonNegative and
Whole numeric types.&. Two list types (or two
data frame types) are merged into one type with the fields of both; any
other combination must satisfy both sides.Refine(type, predicate, message): adds a custom rule
with a custom error message on top of a type.MinLength(type, n), MaxLength(type, n) and
Unique(type). Lengths are counted with
length() (nrow() for data frames), like
NonEmpty() and [n].Nullable(type): like Optional(), but
inside list and data frame types the field must be present
(field: T | null versus field?: T).Default(type, value): replaces NULL with a
default and fills in missing list fields.Coerce(type, using = NULL): converts values before
checking them, for example "42" to 42. A
conversion that would introduce NA is reported as an
error.Pick(), Omit(), Partial(),
Required() and KeyOf() derive new schemas from
list and data frame types.create_list_type() and
create_dataframe_type() gain an extra
argument: "error" (default, unchanged behaviour),
"allow" to keep unknown fields, or "drop" to
remove them.extend() now also works on data frame types and keeps
the base type’s extra setting.typed_function() arguments and
return values now store the parsed value. This only makes a
difference for types that transform values (Default(),
Coerce(), extra = "drop",
FunctionOf()); for every other type the stored value is
exactly the assigned one.type_of(x) returns the declared type of a typed
variable (NULL for regular variables), so one variable’s
type can be reused for another:
y %:% type_of(x) %<-% value.untype(x) turns a typed variable back into a
regular variable.sicher.mode = "warn" option: type violations are
reported as warnings and the assigned value is kept, which helps when
adding sicher to existing code. Readonly() is still
enforced.Scalar() now also accepts union types.infer_type() now infers Factor(),
Date and DateTime instead of
Any.<type: readonly<string> >).R (>= 4.0.0) (needed for
type_of()) and imports methods (used by
InstanceOf() for S4 classes). jsonlite is suggested for
validate_json() and
to_json_schema(json = TRUE).Literal type checkextend method to extend a preexisting
list schema.NonNA() modifier — rejects any value that
contains at least one NA.Between(min, max) — closed-interval numeric
range constraint.Matches(pattern) — PCRE regex-constrained string
type.NonEmpty() modifier — rejects zero-length
vectors, lists, and zero-row data frames.These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.