longshotlabs / simpl-schema

A JavaScript schema validation package that supports direct validation of MongoDB update modifier objects
https://www.npmjs.com/package/simpl-schema
MIT License
560 stars 114 forks source link

Document that the `custom()` function can return an object #235

Open scharf opened 6 years ago

scharf commented 6 years ago

for example:

custom() {
      if (this.value !== this.field('password').value) {
        return { type: "passwordMismatch", message: "Passwords do not match!" };
      }
    },
sophos-rickc commented 4 months ago

@scharf, this is a very nice callout! I was not aware that this is possible. I may use it.

scharf commented 4 months ago

It is now documented Validate one key against another.

scharf commented 4 months ago

ah -- I realized that it is not documented that it can return an object -- to verify this, it would also need a test....