本文整理匯總了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
);
示例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);
示例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);
示例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
};
示例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
}
示例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);