nowjs-core
Version:
NowCanDo Javascript Core [nowjs-core] is a library written by TypeScript code maintains under Apache 2.0 licence
21 lines (20 loc) • 806 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("../index");
const strictMetadataKey = Symbol('StrictValidator');
class StrictValidator extends index_1.ValidatorBase {
constructor(errorMessage = 'The ${DisplayName} is ${Target} not stricted.') {
super('Strict', errorMessage);
}
validate(context) {
if (context.Value === undefined ||
context.Value === null ||
(typeof context.Value === 'string' && context.Value === '')) {
return Promise.reject(new index_1.ValidatorException(this.Name, context.Target, context.PropertyName, this.formatErrorMessage(context)));
}
else {
return Promise.resolve(true);
}
}
}
exports.StrictValidator = StrictValidator;