Skip to content

Return validation result instead of throwing errors #4

Open
@KrishnaPG

Description

@KrishnaPG

It would be great if the error throwing could be replaced with normal function returns (true or false), and let the caller decide to throw or not. in their wrappers if needed.

Its impossible to write below kind of simple code, very useful for pedagogic reasons.

console.log("validation Result for AAA: ", cc.validateFulfillment(fulfillment1, condition));
console.log("validation Result for BBB: ", cc.validateFulfillment(fulfillment2, condition));

Not to mention, trying to validate an array of fulfillments in for loop or Array map or piping with lodash primitives!!

 results = fulfillmentsArray.map(f => cc.validateFulfillment(f, condition);
 _.some(results,  result => { return result == true });

The returned result value could be object (instead of plain boolean value), if required.

   _.some(results,  result => { return result.fulfilled == true });

These kind of things are very very tricky to achieve with throws.

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