Skip to content

Commit

Permalink
feat: add not equal evaluator
Browse files Browse the repository at this point in the history
  • Loading branch information
IamSebastianDev committed Nov 27, 2022
1 parent 93cb255 commit 439ce6b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export {
GreaterThanOrEqual,
LessThanOrEqual,
Unsafe,
NotEqual,
} from './lib/Evaluators';

export type { Collection, ObjectId, JSONDocument } from './lib';
Expand Down
22 changes: 22 additions & 0 deletions src/lib/Evaluators/NotEqual.evaluator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/** @format */

import { EvaluatorFunction } from '../../types';
import { isNonNull } from '../../utils';

/**
* @description
* Method to check if a given value is not equal to a stored property
*
* @param { any } condition - Value to check for being not equal
* @returns { EvaluatorFunction }
*/

export const NotEqual = (...condition: any): EvaluatorFunction => {
return (value: unknown, propName?: string) => {
if (!isNonNull(value)) {
throw new TypeError(`[Query] Property ${propName} is null or undefined.`);
}

return condition !== value;
};
};
1 change: 1 addition & 0 deletions src/lib/Evaluators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export { GreaterThan, GreaterThanOrEqual } from './GreaterThan.evaluator';
export { LessThan, LessThanOrEqual } from './LessThan.evaluator';
export { In } from './In.evaluator';
export { Unsafe } from './Unsafe.evaluator';
export { NotEqual } from './NotEqual.evaluator';

0 comments on commit 439ce6b

Please sign in to comment.