-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nect release with new rules and change logs
- Loading branch information
1 parent
d917ce3
commit c16b0dd
Showing
13 changed files
with
325 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const empty = require('../lib/empty'); | ||
const { pathIndex } = require('../lib/ObjectIndex'); | ||
const numeric = require('./numeric'); | ||
|
||
module.exports = async function gt(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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const empty = require('../lib/empty'); | ||
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const empty = require('../lib/empty'); | ||
const { pathIndex } = require('../lib/ObjectIndex'); | ||
const numeric = require('./numeric'); | ||
|
||
module.exports = async function lt(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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const empty = require('../lib/empty'); | ||
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const assert = require('assert'); | ||
|
||
const Validator = require('../../index'); | ||
|
||
|
||
let r = {}; | ||
|
||
|
||
describe('gt', function () { | ||
|
||
it('validation should pass', async () => { | ||
|
||
const v = new Validator( | ||
{ min: '20', max: '25' }, | ||
{ | ||
min: 'required|integer', | ||
max: 'required|integer|gt:min' | ||
} | ||
); | ||
|
||
const matched = await v.check(); | ||
|
||
assert.equal(matched, true); | ||
|
||
}); | ||
|
||
it('validation should fail', async () => { | ||
|
||
const v = new Validator( | ||
{ min: '30', max: '25' }, | ||
{ | ||
min: 'required|integer', | ||
max: 'required|integer|gt:min' | ||
} | ||
); | ||
|
||
const matched = await v.check(); | ||
|
||
assert.equal(matched, false); | ||
|
||
}); | ||
|
||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const assert = require('assert'); | ||
|
||
const Validator = require('../../index'); | ||
|
||
|
||
let r = {}; | ||
|
||
|
||
describe('gte', function () { | ||
|
||
it('validation should pass with greater seed', async () => { | ||
|
||
const v = new Validator( | ||
{ min: '20', max: '25' }, | ||
{ | ||
min: 'required|integer', | ||
max: 'required|integer|gte:min' | ||
} | ||
); | ||
|
||
const matched = await v.check(); | ||
|
||
assert.equal(matched, true); | ||
|
||
}); | ||
|
||
it('validation should pass with equal', async () => { | ||
|
||
const v = new Validator( | ||
{ min: '20', max: '20' }, | ||
{ | ||
min: 'required|integer', | ||
max: 'required|integer|gte:min' | ||
} | ||
); | ||
|
||
const matched = await v.check(); | ||
|
||
assert.equal(matched, true); | ||
|
||
}); | ||
|
||
it('validation should fail', async () => { | ||
|
||
const v = new Validator( | ||
{ min: '30', max: '25' }, | ||
{ | ||
min: 'required|integer', | ||
max: 'required|integer|gte:min' | ||
} | ||
); | ||
|
||
const matched = await v.check(); | ||
|
||
assert.equal(matched, false); | ||
|
||
}); | ||
|
||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const assert = require('assert'); | ||
|
||
const Validator = require('../../index'); | ||
|
||
|
||
let r = {}; | ||
|
||
|
||
describe('lt', function () { | ||
|
||
it('validation should pass', async () => { | ||
|
||
const v = new Validator( | ||
{ min: '20', max: '25' }, | ||
{ | ||
min: 'required|integer|lt:max', | ||
max: 'required|integer' | ||
} | ||
); | ||
|
||
const matched = await v.check(); | ||
|
||
assert.equal(matched, true); | ||
|
||
}); | ||
|
||
it('validation should fail', async () => { | ||
|
||
const v = new Validator( | ||
{ min: '30', max: '25' }, | ||
{ | ||
min: 'required|integer|lt:max', | ||
max: 'required|integer' | ||
} | ||
); | ||
|
||
const matched = await v.check(); | ||
|
||
assert.equal(matched, false); | ||
|
||
}); | ||
|
||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const assert = require('assert'); | ||
|
||
const Validator = require('../../index'); | ||
|
||
|
||
let r = {}; | ||
|
||
|
||
describe('lte', function () { | ||
|
||
it('validation should pass with greater seed', async () => { | ||
|
||
const v = new Validator( | ||
{ min: '20', max: '25' }, | ||
{ | ||
min: 'required|integer|lte:max', | ||
max: 'required|integer' | ||
} | ||
); | ||
|
||
const matched = await v.check(); | ||
|
||
assert.equal(matched, true); | ||
|
||
}); | ||
|
||
it('validation should pass with equal', async () => { | ||
|
||
const v = new Validator( | ||
{ min: '20', max: '20' }, | ||
{ | ||
min: 'required|integer|lte:max', | ||
max: 'required|integer' | ||
} | ||
); | ||
|
||
const matched = await v.check(); | ||
|
||
assert.equal(matched, true); | ||
|
||
}); | ||
|
||
it('validation should fail', async () => { | ||
|
||
const v = new Validator( | ||
{ min: '30', max: '25' }, | ||
{ | ||
min: 'required|integer|lte:max', | ||
max: 'required|integer' | ||
} | ||
); | ||
|
||
const matched = await v.check(); | ||
|
||
assert.equal(matched, false); | ||
|
||
}); | ||
|
||
|
||
}); |