Skip to content

Commit c111346

Browse files
committed
Add NotEmpty validation message
1 parent 81f8b7e commit c111346

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

lib/annotations/validation/NotEmpty.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,21 @@ import {addAttributeOptions} from "../../services/models";
44
/**
55
* Don't allow empty strings
66
*/
7-
export function NotEmpty(target: any, propertyName: string): void {
7+
export function NotEmpty({msg}: {msg?: string}): Function {
88

9-
addAttributeOptions(target, propertyName, {
10-
validate: {
11-
notEmpty: true
12-
}
13-
});
9+
let options: boolean | {msg: string};
10+
11+
if (msg) {
12+
options = {msg};
13+
} else {
14+
options = true;
15+
}
16+
17+
return (target: any, propertyName: string) => {
18+
addAttributeOptions(target, propertyName, {
19+
validate: {
20+
notEmpty: options
21+
}
22+
});
23+
}
1424
}

0 commit comments

Comments
 (0)