sat-compare
v0.0.4
Published
Universal comparison library
Downloads
6,015
Maintainers
Readme
SAT COMPARISON LIBRARY
Content
- customCheck
- stringIncludes
- stringLowercase
- stringUppercase
- checkEmptyStrings
- checkStringLength
- ignoreNonStringsTypes
- dataIncldesPatternPart
- dataIncludesMembers
- patternIncludesMembers
customCheck
const { compare } = require('sat-compare');
{
const data = { prop: ' test ' };
const check = { prop: text => text.includes('test') };
const { result, message } = compare(data, check, { customCheck: true });
// result true
// message ''
}
{
const data = { prop: [2, 4, 6] };
const check = { prop: arr => arr.every(i => i % 2 === 0) };
const { result, message } = compare(data, check, { customCheck: true });
// result true
// message ''
}
stringIncludes
const { compare } = require('sat-compare');
{
const data = { prop: ' test ' };
const check = { prop: 't' };
const { result, message } = compare(data, check, { stringIncludes: true });
// result true
// message ''
}
stringLowercase
const { compare } = require('sat-compare');
{
const data = { prop: 'TEST' };
const check = { prop: 'test' };
const { result, message } = compare(data, check, { stringLowercase: true });
// result true
// message ''
}
stringUppercase
const { compare } = require('sat-compare');
{
const data = { prop: 'TEST' };
const check = { prop: 'test' };
const { result, message } = compare(data, check, { stringUppercase: true });
// result true
// message ''
}
checkEmptyStrings
const { compare } = require('sat-compare');
{
const data = { prop: 'TEST' };
const check = {};
const { result, message } = compare(data, check, { checkEmptyStrings: true });
// result true
// message ''
}
checkStringLength
const { compare } = require('sat-compare');
{
const data = { prop: 'TEST' };
const check = { prop: { length: '>2' } };
const { result, message } = compare(data, check, { checkStringLength: true });
// result true
// message ''
}
{
const data = { prop: 'TEST' };
const check = { prop: { length: 4 } };
const { result, message } = compare(data, check, { checkStringLength: true });
// result true
// message ''
}
ignoreNonStringsTypes
const { compare } = require('sat-compare');
{
const data = { prop1: '1', prop2: 2 };
const check = { prop1: '1', prop2: 3 };
const { result, message } = compare(data, check, { ignoreNonStringsTypes: true });
// result true
// message ''
}
dataIncldesPatternPart
const { compare } = require('sat-compare');
{
const data = { prop1: '1', prop2: 2, prop3: 3 };
const check = { prop1: '1', prop4: 3, prop5: 5 };
const { result, message } = compare(data, check, { dataIncldesPatternPart: true });
// result true
// message ''
}
dataIncludesMembers
const { compare } = require('sat-compare');
{
const data = { prop1: { a: [1, 2, 3, 4] } };
const check = { prop1: { a: [1, 3, 2] } };
const { result, message } = compare(data, check, { dataIncludesMembers: true });
// result true
// message ''
}