Skip to content

Commit 32cfb67

Browse files
committed
Set type to definition of the Present validator
1 parent 6532506 commit 32cfb67

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lib/validators/present.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ export interface IPresentValidatorDefinition extends IBaseValidatorDefinition {}
1313
export class PresentValidator implements IValidator<any, IPresentValidatorDefinition> {
1414
private static rWhiteSpace: RegExp = /^[\t\n\v\f\r ]*$/;
1515

16-
constructor(public definition: IPresentValidatorDefinition) {}
16+
constructor(public definition: IPresentValidatorDefinition) {
17+
this.definition.type = "present";
18+
}
1719

1820
public validate(input: any): IValidationError<any, IPresentValidatorDefinition> {
1921
const invalid = {

test/present_test.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ describe("PresentValidator", () => {
66
describe("validate", () => {
77

88
it(`should be invalid if the input is undefined or null`, () => {
9-
const definition = {};
9+
const definition = {
10+
type: "present",
11+
};
1012
const validator = new PresentValidator({});
1113
[
1214
{
@@ -30,7 +32,9 @@ describe("PresentValidator", () => {
3032
});
3133

3234
it(`should be invalid if the input consisting only white space`, () => {
33-
const definition = {};
35+
const definition = {
36+
type: "present",
37+
};
3438
const validator = new PresentValidator({});
3539
[
3640
{
@@ -111,7 +115,9 @@ describe("PresentValidator", () => {
111115
});
112116

113117
it(`should be invalid if the input is empty array`, () => {
114-
const definition = {};
118+
const definition = {
119+
type: "present",
120+
};
115121
const validator = new PresentValidator({});
116122
[
117123
{
@@ -132,7 +138,9 @@ describe("PresentValidator", () => {
132138
});
133139

134140
it(`should be invalid if the input is empty object`, () => {
135-
const definition = {};
141+
const definition = {
142+
type: "present",
143+
};
136144
const validator = new PresentValidator({});
137145
[
138146
{

0 commit comments

Comments
 (0)