How to use the aurelia-validation.ValidationRules.ensure function in aurelia-validation

To help you get started, we’ve selected a few aurelia-validation examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github process-engine / bpmn-studio / src / modules / solution-explorer / solution-explorer-solution / solution-explorer-solution.ts View on Github external
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;
      })
github SpoonX / aurelia-orm / test / resources / entity / with-validation.js View on Github external
constructor() {
    super();

    ValidationRules
      .ensure('foo').required().minLength(10).maxLength(20)
      .on(this);
  }
}
github MayGo / tockler / src / welcome.ts View on Github external
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) {
github process-engine / bpmn-studio / src / modules / design / property-panel / indextabs / general / sections / pool / pool.ts View on Github external
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);
  }
github Vheissu / builtwithaurelia / src / routes / dashboard / submissions.ts View on Github external
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;
    }
github stamp-web / stamp-web-aurelia / src / resources / elements / stamps / stamp-details.js View on Github external
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);
    }
github freshcutdevelopment / Aurelia-in-Action / Chapter-7-Complete / my-books / src / resources / elements / edit-book.js View on Github external
}

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);
github freshcutdevelopment / Aurelia-in-Action / Chapter-7 / Listing_7.16_edit-book.js View on Github external
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);
github process-engine / bpmn-studio / src / modules / design / property-panel / indextabs / general / sections / pool / pool.ts View on Github external
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);
  }
github stamp-web / stamp-web-aurelia / src / views / catalogues / catalogue-editor.js View on Github external
setupValidation() {
        ValidationRules
            .ensure('name')
            .required().withMessage(this.i18n.tr('messages.nameRequired'))
            .ensure('issue')
            .satisfies(obj => obj > 1000)
            .on(this.model);

    }