Skip to content

sequenceValidation doesn't work for Fail as stated in docs #250

Description

@jtzero

the docs state that Failures will be accumulated in a list

monet.js/docs/LIST.md

Lines 316 to 332 in 5668595

```javascript
List.fromArray([
Success("a"),
Success("b"),
Success("c")
]).sequenceValidation()
// => Success(List("a", "b", "c"))
List.fromArray([
Success("a"),
Success("b"),
Fail("c"),
Fail("d"),
Success("e")
]).sequenceValidation()
// => Fail(List("c", "d"))
```

const { Success, Fail, List } = require("monet");

> List.fromArray([
...   Success("a"),
...   Success("b"),
...   Success("c")
... ]).sequenceValidation()
{
  val: {
    isNil: false,
    head_: 'a',
    tail_: {
      isNil: false,
      head_: 'b',
      tail_: [Object],
      size_: 2,
      '@@type': 'monet.js/List'
    },
    size_: 3,
    '@@type': 'monet.js/List'
  },
  isSuccessValue: true,
  '@@type': 'monet.js/Validation'
}
> // => Success(List("a", "b", "c"))
undefined
>
> List.fromArray([
...   Success("a"),
...   Success("b"),
...   Fail("c"),
...   Fail("d"),
...   Success("e")
... ]).sequenceValidation()
{ val: 'cd', isSuccessValue: false, '@@type': 'monet.js/Validation' }

And unless I;ve done this wrong, the type in the second example is returned as a string and not a list

    "monet": "^0.9.3",
> node --version
v16.13.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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