How to use the aurelia-validation.validateTrigger.changeOrBlur 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 adarshpastakia / aurelia-ui-framework / src / index.ts View on Github external
export function configure(config: { container: Container, globalResources?: (...resources: string[]) => any }, configCallback) {
  UIUtils.auContainer = config.container;
  document.documentElement.classList.add(window.browserAgent());

  ValidationController.prototype.validateTrigger = validateTrigger.changeOrBlur;
  config.container.registerHandler('ui-validator', container => container.get(UIValidationRenderer));
  if (config.globalResources) {
    // Core Elements
    config.globalResources(
      PLATFORM.moduleName('./elements/core/ui-grid'),
      PLATFORM.moduleName('./elements/core/ui-page'),
      PLATFORM.moduleName('./elements/core/ui-viewport')
    );
    // Input Elements
    config.globalResources(
      PLATFORM.moduleName('./elements/inputs/ui-button'),
      PLATFORM.moduleName('./elements/inputs/ui-date'),
      PLATFORM.moduleName('./elements/inputs/ui-form'),
      PLATFORM.moduleName('./elements/inputs/ui-input'),
      PLATFORM.moduleName('./elements/inputs/ui-lists'),
      PLATFORM.moduleName('./elements/inputs/ui-options'),
github adarshpastakia / aurelia-ui-framework / src / resources / index.ts View on Github external
export function configure(config: { container: Container, globalResources?: (...resources: string[]) => any }, configCallback) {
  UIUtils.auContainer = config.container;
  document.documentElement.classList.add(window.browserAgent());

  ValidationController.prototype.validateTrigger = validateTrigger.changeOrBlur;
  config.container.registerHandler('ui-validator', container => container.get(UIValidationRenderer));
  // Core Elements
  config.globalResources(
    PLATFORM.moduleName('./elements/core/ui-grid'),
    PLATFORM.moduleName('./elements/core/ui-page'),
    PLATFORM.moduleName('./elements/core/ui-viewport')
  );
  // Input Elements
  config.globalResources(
    PLATFORM.moduleName('./elements/inputs/ui-button'),
    PLATFORM.moduleName('./elements/inputs/ui-date'),
    PLATFORM.moduleName('./elements/inputs/ui-form'),
    PLATFORM.moduleName('./elements/inputs/ui-input'),
    PLATFORM.moduleName('./elements/inputs/ui-lists'),
    PLATFORM.moduleName('./elements/inputs/ui-options'),
    PLATFORM.moduleName('./elements/inputs/ui-phone'),
github adarshpastakia / aurelia-ui-framework / dist / native-modules / aurelia-ui-framework.js View on Github external
var registerValidators = function (container) {
    container.get(ValidationController).validateTrigger = validateTrigger.changeOrBlur;
    ValidationRules.customRule("url", function (value) {
        return value === null ||
            value === undefined ||
            value === "" ||
            /^((http[s]?|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-.]+[^#?\s]+)(.*)?(#[\w\-]+)?$/.test(value);
    }, "\${$displayName} is not a valid url.");
    ValidationRules.customRule("phone", function (value) {
        return value === null || value === undefined || value === "" || parsePhoneNumberFromString(value).isValid();
    }, "\${$displayName} is not a valid phone number.");
    ValidationRules.customRule("number", function (value, obj, min, max) {
        return value === null ||
            value === undefined ||
            value === "" ||
            (isNumber(value) &&
                value >= (isEmpty(min) ? Number.MIN_VALUE : min) &&
                value <= (isEmpty(max) ? Number.MAX_VALUE : max));
github adarshpastakia / aurelia-ui-framework / dist / es2015 / aurelia-ui-framework.js View on Github external
const registerValidators = (container) => {
    container.get(ValidationController).validateTrigger = validateTrigger.changeOrBlur;
    ValidationRules.customRule("url", (value) => value === null ||
        value === undefined ||
        value === "" ||
        /^((http[s]?|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-.]+[^#?\s]+)(.*)?(#[\w\-]+)?$/.test(value), "\${$displayName} is not a valid url.");
    ValidationRules.customRule("phone", (value) => value === null || value === undefined || value === "" || parsePhoneNumberFromString(value).isValid(), "\${$displayName} is not a valid phone number.");
    ValidationRules.customRule("number", (value, obj, min, max) => value === null ||
        value === undefined ||
        value === "" ||
        (isNumber(value) &&
            value >= (isEmpty(min) ? Number.MIN_VALUE : min) &&
            value <= (isEmpty(max) ? Number.MAX_VALUE : max)), "\${$displayName} must be an number value between \${$config.min} and \${$config.max}.", (min, max) => ({ min, max }));
    ValidationRules.customRule("decimal", (value, obj, min, max) => value === null ||
        value === undefined ||
        value === "" ||
        (isDecimal(value) &&
            value >= (isEmpty(min) ? Number.MIN_VALUE : min) &&
github adarshpastakia / aurelia-ui-framework / src / forms / ui-validation.ts View on Github external
export const registerValidators = (container: Container) => {
  container.get(ValidationController).validateTrigger = validateTrigger.changeOrBlur;

  ValidationRules.customRule(
    "url",
    (value) =>
      value === null ||
      value === undefined ||
      value === "" ||
      /^((http[s]?|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-.]+[^#?\s]+)(.*)?(#[\w\-]+)?$/.test(
        value
      ),
    "\${$displayName} is not a valid url."
  );
  ValidationRules.customRule(
    "phone",
    (value) =>
      value === null || value === undefined || value === "" || parsePhoneNumberFromString(value).isValid(),
github adarshpastakia / aurelia-ui-framework / src / resources / elements / components / ui-datagrid.ts View on Github external
constructor(public element: Element, factory: ValidationControllerFactory) {
    this.virtual = element.hasAttribute('virtual');
    this.editable = element.hasAttribute('editable');
    this.rowCounter = element.hasAttribute('row-counter');
    this.rowExpander = element.hasAttribute('row-expander');
    if (!element.hasAttribute('scroll')) this.element.classList.add('ui-auto-size');
    if (element.hasAttribute('hilight')) this.element.classList.add('ui-hilight');

    if (this.editable) {
      this.controller = factory.createForCurrentScope();
      this.controller.validateTrigger = validateTrigger.changeOrBlur;
    }
  }
github adarshpastakia / aurelia-ui-framework / src / inputs / validation.ts View on Github external
constructor(public element: Element, controllerFactory: ValidationControllerFactory) {
    this.controller = controllerFactory.createForCurrentScope();
    this.controller.validateTrigger = validateTrigger.changeOrBlur;
    this.controller.addRenderer(new UIValidationRenderer());
    this.model = new DataModel();
  }
github adarshpastakia / aurelia-ui-framework / examples / src / inputs / validation.ts View on Github external
constructor(public controller: ValidationController) {
    this.model = new DataModel();
    this.controller.validateTrigger = validateTrigger.changeOrBlur;
  }