var jobSchema = Schema({ negotiation: { state: { type: String, required: hasNegotiation } } }); function hasNegotiation() { return this.negotiation && Object.keys(this.negotiation).length > 0; }