Class-validator: @IsUrl options not works

Created on 6 Nov 2016  路  9Comments  路  Source: typestack/class-validator

It seems what @IsURL options not works at all.

   /**
     * @type {string}
     */
    @IsString()
    @ValidateIf((options: IOptions) => Boolean(options.sourceMapBaseUrl))
    @IsUrl({
        require_protocol: true,
        require_valid_protocol: true
    })
    public readonly sourceMapBaseUrl: string;

Input string google.ru -> validator does not trows any errors.

Most helpful comment

fixed your issue in 0.6.6

All 9 comments

ping

as you know IsUrl just delegates its work to https://github.com/chriso/validator.js isUrl. Can you check if what you try to achieve works with original function? e.g. require("validator").isURL(value, options)

https://runkit.com/58259b2fcfbc960014b4591f/582ab7ae430fac0014ffc6d4

    require("validator").isURL('google.ru', {
        require_protocol: true,
        require_valid_protocol: true
    })

returns false

Looks like class-validator not passes options for isURL validator.

try fix in 0.6.5

ts error with 0.6.5
Cannot find type definition file for 'es6-shim'.

[default] /home/user/javascript-obfuscator/node_modules/class-validator/decorator/decorators.d.ts:2:1 
    Cannot find type definition file for 'es6-shim'.
[default] /home/user/javascript-obfuscator/node_modules/class-validator/index.d.ts:2:1 
    Cannot find type definition file for 'es6-shim'.
[default] /home/user/javascript-obfuscator/node_modules/class-validator/validation/Validator.d.ts:2:1 
    Cannot find type definition file for 'es6-shim'.
[default] /home/user/javascript-obfuscator/node_modules/class-validator/validation/ValidatorConstraintInterface.d.ts:1:1 
    Cannot find type definition file for 'es6-shim'.

damn this is problem with new @types system... I'll fix it, but despite the compiler errors, is isUrl working now?

looks like now it works

fixed your issue in 0.6.6

Amazing, thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

golozubov picture golozubov  路  5Comments

jerradpatch picture jerradpatch  路  4Comments

binaryangel-noa picture binaryangel-noa  路  3Comments

AndyBarron picture AndyBarron  路  3Comments

btd1337 picture btd1337  路  5Comments