silfverorg / duns.js

Javascript schema validator
5 stars 2 forks source link

Added 'allowAllKeys' to Duns.object(). Closes #41. #44

Closed silfverstrom closed 9 years ago

silfverstrom commented 9 years ago

Normally, all none specified keys would cause validation to fail. 'allowAllKeys' alters this behavior, and accepts none specified keys.

Can be used with

    var schema = Duns.object().keys({
      shouldExist: Duns.number(),
    }).allowAllKeys();

    var obj = {
      shouldExist: 20,
      test1: 100,
    };
    schema.validate(obj); // Returns true