Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private setValidationRules(): void {
ValidationRules.ensure((state: IDiagramNameInputState) => state.currentDiagramInputValue)
.required()
.withMessage('Diagram name cannot be blank.')
.satisfies((input: string) => {
const inputIsNotEmpty: boolean = input !== undefined;
const inputAsCharArray: Array = inputIsNotEmpty ? input.split('') : [];
const diagramNamePassesNameChecks: boolean = inputAsCharArray.every((letter: string) => {
// tslint:disable-next-line:typedef
const letterMatches = (regExp: RegExp): boolean => regExp.test(letter);
return this.diagramValidationRegExpList.some(letterMatches);
});
return diagramNamePassesNameChecks;
})
constructor() {
super();
ValidationRules
.ensure('foo').required().minLength(10).maxLength(20)
.on(this);
}
}
constructor(private i18n: I18N, private element: Element, private ea: EventAggregator, controller: ValidationController,
private trackItemService: TrackItemService) {
this.controller = controller;
this.controller.addRenderer(new MaterializeFormValidationRenderer());
ea.subscribe('i18n:locale:changed', payload => {
this.i18n.updateTranslations(this.element);
});
ValidationRules
.ensure('firstName')
.required()
.ensure('lastName')
.required()
.minLength(3)
.on(this);
this.status.chromeVersion = process.versions.chrome;
this.status.electronVersion = process.versions.electron;
this.status.nodeVersion = process.versions.node;
this.status.v8Version = process.versions.v8;
var startDate = moment();
startDate.startOf('day');
console.log(trackItemService)
trackItemService.findAllFromDay(startDate.toDate(), 'AppTrackItem').then(function (items) {
private setValidationRules(): void {
ValidationRules.ensure((businessObject: IModdleElement) => businessObject.id)
.displayName('processId')
.required()
.withMessage('Process-ID cannot be blank.')
.then()
.satisfies((id: string) => this.formIdIsUnique(id) && this.isProcessIdUnique(id))
.withMessage('Process-ID already exists.')
.on(this.businessObjInPanel.processRef);
}
constructor(private api: Api, private controllerFactory: ValidationControllerFactory, private validator: Validator) {
this.controller = controllerFactory.createForCurrentScope();
this.controller.subscribe(event => this.validateForm(event));
ValidationRules
.ensure('description').required()
.ensure('url').required().when((submission: any) => (submission.repoUrl.trim() === ''))
.on(this.submission).rules;
}
setupValidation() {
ValidationHelper.defineNumericRangeRule( ValidationRules, 'country-selection',0);
ValidationRules
.ensure('rate')
.required().withMessage(this.i18n.tr('messages.rateRequired'))
.ensure('description')
.required().withMessage(this.i18n.tr('messages.descriptionRequired'))
.ensure('countryRef')
.required().withMessage(this.i18n.tr('messages.countryRequired'))
.satisfiesRule('country-selection').withMessage(this.i18n.tr('messages.countryRequired'))
.on(this.model);
}
}
export class Book {
title='';
description='';
timesRead = 0;
}
ValidationRules.customRule(
'positiveInteger',
(value, obj) => value === null || value === undefined
|| (Number.isInteger(value) || value >= 0),
`Books can only be read 0 or more times.`
);
ValidationRules
.ensure(a => a.title).required()
.ensure('timesRead')
.required()
.satisfiesRule('positiveInteger')
.on(Book);
export class Book {
title = "";
description = "";
timesRead = 0;
}
ValidationRules.customRule(
"zeroOrPositiveInteger",
(value, obj) =>
value === null ||
value === undefined ||
(Number.isInteger(value) || value >= 0),
`Books can only be read 0 or more times.`
);
ValidationRules.ensure(a => a.title)
.required()
.ensure("timesRead")
.required()
.satisfiesRule("zeroOrPositiveInteger")
.on(Book);
private _setValidationRules(): void {
ValidationRules.ensure((businessObject: IModdleElement) => businessObject.id)
.displayName('processId')
.required()
.withMessage('Process-ID cannot be blank.')
.then()
.satisfies((id: string) => this._formIdIsUnique(id) && this._isProcessIdUnique(id))
.withMessage('Process-ID already exists.')
.on(this.businessObjInPanel.processRef);
}
setupValidation() {
ValidationRules
.ensure('name')
.required().withMessage(this.i18n.tr('messages.nameRequired'))
.ensure('issue')
.satisfies(obj => obj > 1000)
.on(this.model);
}