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";
44/**
55 * Don't allow empty strings
66 */
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 {
810
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+ } ) ;
1321 } else {
14- options = true ;
15- }
16-
17- return ( target : any , propertyName : string ) => {
22+
23+ const target = args [ 0 ] ;
24+ const propertyName = args [ 1 ] ;
25+
1826 addAttributeOptions ( target , propertyName , {
1927 validate : {
20- notEmpty : options
28+ notEmpty : true
2129 }
2230 } ) ;
2331 }
You can’t perform that action at this time.
0 commit comments