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

Promise Validation is inconsistent #59

@kyeotic

Description

@kyeotic

In synchronous validators returning a string indicates an error message. Promises should treat resolves just like returns, meaning a promise that resolving a string is analogous to a function that returns a string.

Async validators, though, require a promise to be rejected with a string. Resolving with a string is ignored. The different semantics mean that you cannot just return a call to validate(someStuff) inside of your promise, once your async work has completed. You have to wrap the result, and either resolve or reject according to it.

This is not consistent with standard promise semantics. Not only that, it complicates the code. It would be much easier to just return result inside of the promise code, knowing that if result is null an error won't be displayed, and if result is an error it will be displayed.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions