Skip to content

Commit

Permalink
more misc doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
leafo committed Oct 6, 2023
1 parent f832349 commit 9b333af
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions docs/input_validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,14 @@ $options_table{

#### `types.params_array(t, [opts])`

Creates a type checker that will array components from a table. Each item in
the array must match type `t`. Any other items in the table that are not part
of the array component of the table are ignored and not returned in the final
result. A new table is always returned in the transformed output, even if no
changes are made to any of the values. Like `params_shape`, errors are
accumulated into an array object. Every value will be checked for failure, even
if a single value fails validation, there is no short circuiting.

The `opts` argument can be a table of options to control how the type checker
Creates a type checker that extracts array components from a table. Every item
in the array must match type `t`, otherwise the checker will fail. Any other
items in the table, not part of the array component, are ignored and not
included in the final result. A new table is always returned in the transformed
output, even if no changes have been made to any of the values. Similar to
`params_shape`, errors are accumulated into an array object.

The `opts` argument is a table of options that control how the type checker
processes the input:

$options_table{
Expand All @@ -232,13 +231,13 @@ $options_table{

#### `types.assert_error(t)`

Wraps a Tableshape type checker to yield an error when checking/transforming
fails. The yielded error is compatible with Lapis error handling (eg.
`assert_error` & `capture_errors`).
Wraps a Tableshape type checker, `t`, to yield an error when the checking or
transforming process fails. The error yielded is compatible with Lapis error
handling, such as `assert_error` and `capture_errors`.

This can be used to simplify code paths, as it is no longer necessary to check
for the error case when validating an input since the error will be passed up
the stack to the enclosing `capture_errors`.
This can be utilized to simplify code paths, as it eliminates the need to check
for an error case when validating an input. The error will be automatically
passed up the stack to the enclosing `capture_errors`.

$dual_code{
moon = [[
Expand All @@ -255,17 +254,18 @@ print "We are guaranteed to have an empty value"

#### `types.flatten_errors(t)`

Converts errors that may be contained in an array table into a single string
Converts errors that might be contained in an array table into a single string
error message.

The constructors `params_shape` and `params_array` accumulate errors into an
array table to allow better error reporting to end-users. This error format is
not compatible with standard tableshape error handling though, as a single
string is expected. This will ensure that any error messsages generated by the
array table to enhance error reporting for end-users. However, this error
format is not compatible with standard tableshape error handling, as it expects
a single string. This ensures that any error messages generated by the
contained type, `t`, are single strings.

If an array of errors is encountered, they are joined by `", "`.


### Builtin types

#### `types.empty`
Expand Down

0 comments on commit 9b333af

Please sign in to comment.