Skip to content

object

Describes a typed object via a dictionary of parsers. DDataParser.object() builds a structured schema, applies each child parser, aggregates errors with their path (user.address.city), and returns the validated immutable value.

Interactive example

Parameters

  • shape: dictionary { key: DataParser } (all available parsers are accepted, including those composed via pipe).
  • checkers: checkerRefine and custom helpers to validate the complete result (e.g. check inter-field dependencies).
  • errorMessage: general message used when the input is not a valid object.

Return value

A DataParserObject with the methods parse, asyncParse, exec, asyncExec, addChecker, clone. schema.parse(data) returns DEither.success<Shape> if everything passes or DEither.error<DataParserError> grouping all issues.

Other examples

Custom checkers

Extended mode

Projection with pick

Select only the publicly exposed fields from a larger schema.

Standard version

Extended version

Masking with omit

Remove secrets (password, tokens, etc.) before returning your objects.

Standard version

Extended version

Extension with extends

Rebuild a schema while keeping a base and adding extra properties.

Standard version

Extended version

Update schema with partial

Make all keys optional (useful for patch/update payloads) without losing field validations.

Standard version

Extended version

Required fields with required

Remove optionality (optional wrappers) on an object schema: useful after a partial or if you marked fields optional too early.

Standard version

Extended version

See also

Released under the MIT license.