Closed Kshatra closed 7 years ago
I have a simple schema for equality check on 2 fields:
const checkEqualSchema = new SimpleSchema({ field1: { type: String, }, field2: { type: String, custom() { if ( this.field('field1').value != this.value ) { checkEqualSchema.namedContext('context1').addInvalidKeys([ {name: "field1", type: "fieldsMustMatch"}, {name: "field2", type: "fieldsMustMatch"} ]); } } }, }); var doc = { field1: 'value1', field2: 'value2' }, ssContext = checkEqualSchema.namedContext("context1"); ssContext.validate(doc); console.log('isValid: ',ssContext.isValid()); // true
Why is doc considered valid even if i add invalid keys in "custom" schema field?
I have a simple schema for equality check on 2 fields:
Why is doc considered valid even if i add invalid keys in "custom" schema field?