File tree Expand file tree Collapse file tree 1 file changed +18
-10
lines changed
lib/annotations/validation Expand file tree Collapse file tree 1 file changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -4,20 +4,28 @@ import {addAttributeOptions} from "../../services/models";
4
4
/**
5
5
* Don't allow empty strings
6
6
*/
7
- export function NotEmpty ( { msg} : { msg ?: string } ) : Function {
7
+ export function NotEmpty ( target : any , propertyName : string ) : void ;
8
+ export function NotEmpty ( options : { msg : string } ) : Function ;
9
+ export function NotEmpty ( ...args : any [ ] ) : void | Function {
8
10
9
- let options : boolean | { msg : string } ;
10
-
11
- if ( msg ) {
12
- options = { msg} ;
11
+ if ( args . length === 1 ) {
12
+
13
+ const options = args [ 0 ] ;
14
+
15
+ return ( target : any , propertyName : string ) =>
16
+ addAttributeOptions ( target , propertyName , {
17
+ validate : {
18
+ notEmpty : options ,
19
+ }
20
+ } ) ;
13
21
} else {
14
- options = true ;
15
- }
16
-
17
- return ( target : any , propertyName : string ) => {
22
+
23
+ const target = args [ 0 ] ;
24
+ const propertyName = args [ 1 ] ;
25
+
18
26
addAttributeOptions ( target , propertyName , {
19
27
validate : {
20
- notEmpty : options
28
+ notEmpty : true
21
29
}
22
30
} ) ;
23
31
}
You can’t perform that action at this time.
0 commit comments