Skip to content
This repository was archived by the owner on Dec 19, 2022. It is now read-only.
This repository was archived by the owner on Dec 19, 2022. It is now read-only.

Make s.object() confirm to the standard matcher(options) #39

@rprieto

Description

@rprieto

Strummer matchers usually have several forms:

  • a canonical version which takes options, like like s.array({of: matcher, min :1})
  • shorthand helpers like s.array(matcher)

object is the only exception, because the canonical version is s.object(fields). This means the matcher can never have an other options. It would be a breaking change, but I suggest we should change to s.object({props: ...}), which would allow for things like

s.object({
  optional: true,     // can be null
  allowExtra: true,   // don't fail if there's additional properties to the ones below
  props: { ... }      // list of properties
})

We could still have the top-level shorthand s(someObject) which would delegate to s.object({props: someObject}).

Note: this would remove the need for s.objectOnly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions