node-input-validator
Version:
validation library for nodejs, inspired by laravel.
17 lines (12 loc) • 393 B
JavaScript
const { pathIndex } = require('../lib/ObjectIndex');
const numeric = require('./numeric');
module.exports = async function gte(field, value, anotherField) {
const anotherFieldValue = pathIndex(this.inputs, anotherField);
if (!(await numeric(field, anotherFieldValue))) {
return false;
}
if (Number(value) <= Number(anotherFieldValue)) {
return true;
}
return false;
};