當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript lc-form-validation.createFormValidation函數代碼示例

本文整理匯總了TypeScript中lc-form-validation.createFormValidation函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript createFormValidation函數的具體用法?TypeScript createFormValidation怎麽用?TypeScript createFormValidation使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了createFormValidation函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: createFormValidation

import {
  createFormValidation,
  ValidationConstraints,
  Validators
} from "lc-form-validation";

const loginFormValidationConstraints: ValidationConstraints = {
  fields: {
    login: [{ validator: Validators.required }],
    password: [{ validator: Validators.required }]
  }
};

export const loginFormValidation = createFormValidation(
  loginFormValidationConstraints
);
開發者ID:Lemoncode,項目名稱:react-typescript-samples,代碼行數:16,代碼來源:loginPage.validation.ts

示例2: hasItems

import {
  ValidationConstraints, createFormValidation, Validators
} from 'lc-form-validation';
import {hasItems} from '../../../../common/validations/arrayValidation';

const constraints: ValidationConstraints = {
  fields: {
    name: [
      { validator: Validators.required }
    ],
    ingredients: [
      { validator: hasItems('Should have at least one ingredient')}
    ]
  }
};

export const editFormValidation = createFormValidation(constraints);
開發者ID:Lemoncode,項目名稱:lcFormValidation,代碼行數:17,代碼來源:editFormValidation.ts

示例3: createFormValidation

import {
  Validators, ValidationConstraints, createFormValidation
} from 'lc-form-validation';

const validationConstraints: ValidationConstraints = {
  fields: {
    login: [
      { validator: Validators.required },
      {
        validator: Validators.minLength,
        customParams: { length: 3 },
      },
    ]
  },
};

export const memberFormValidation = createFormValidation(validationConstraints);
開發者ID:Lemoncode,項目名稱:react-typescript-samples,代碼行數:17,代碼來源:memberFormValidation.ts

示例4: createFormValidation

import {
  ValidationConstraints,
  Validators,
  createFormValidation,
  RequiredParams,
} from 'lc-form-validation';

const customerValidationConstraints: ValidationConstraints = {
  fields: {
    fullname: [
      { validator: Validators.required }
    ],
    password: [
      { validator: Validators.required }
    ],
  }
};
const customerFormValidation = createFormValidation(customerValidationConstraints);

export {
  customerFormValidation
};
開發者ID:Lemoncode,項目名稱:lcFormValidation,代碼行數:22,代碼來源:customerFormValidation.ts

示例5: isAnyQuestionSelected

import { FieldValidationResult, createFormValidation } from 'lc-form-validation';
import { QuizEntity, Question } from '../../../entity/quizEntity';

function isAnyQuestionSelected(quiz: QuizEntity) {
  return Object.keys(quiz).some(question => (quiz[question] as Question).isSelected);
}

function quizValidation(quiz: QuizEntity) {
  const isQuizPassed = isAnyQuestionSelected(quiz);
  const errorInfo = (isQuizPassed) ? '' : 'Failed';
  const fieldValidationResult: FieldValidationResult = new FieldValidationResult();

  fieldValidationResult.type = 'QUIZ_VALIDATION';
  fieldValidationResult.succeeded = isQuizPassed;
  fieldValidationResult.errorMessage = errorInfo;
  return fieldValidationResult;
}

const quizValidationConstraints = {
  global: [
    quizValidation
  ]
};

const quizFormValidation = createFormValidation(quizValidationConstraints);

export {
  quizFormValidation
}
開發者ID:Lemoncode,項目名稱:lcFormValidation,代碼行數:29,代碼來源:quizFormValidation.ts

示例6: createFormValidation

  return Promise.resolve(fieldValidationResult);
}

const signupValidationConstraints: ValidationConstraints = {
  fields: {
    password: [
      { validator: Validators.required },
      {
        validator: Validators.minLength,
        customParams: { length: 4 },
      },
    ],
    confirmPassword: [
      { validator: Validators.required },
      { validator: passwordAndConfirmPasswordValidationHandler },
    ],
    login: [
      {
        validator: Validators.required,
        eventsFilter: { onChange: true, onBlur: true },
      },
      {
        validator: loginExistOnGitHubValidationHandler,
        eventsFilter: { onBlur: true }
      },
    ]
  }
};

export const signupFormValidation = createFormValidation(signupValidationConstraints);
開發者ID:Lemoncode,項目名稱:lcFormValidation,代碼行數:30,代碼來源:signupFormValidation.ts


注:本文中的lc-form-validation.createFormValidation函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。