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


TypeScript MixedSchema.typeError方法代碼示例

本文整理匯總了TypeScript中yup.MixedSchema.typeError方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript MixedSchema.typeError方法的具體用法?TypeScript MixedSchema.typeError怎麽用?TypeScript MixedSchema.typeError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yup.MixedSchema的用法示例。


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

示例1:

mixed.concat(yup.string());
mixed.validate({});
mixed.validate({ hello: 'world' }, { strict: true }).then(value => value);
mixed.isValid(undefined, (valid: true) => true);
mixed.isValid({ hello: 'world' }).then(valid => valid);
mixed.cast({});
mixed.isType('hello');
mixed.strict(true);
mixed.strip(true);
mixed.withMutation(schema => {});
mixed.default({ number: 5});
mixed.default(() => ({ number: 5}));
mixed.default();
mixed.nullable(true);
mixed.required();
mixed.typeError('type error');
mixed.oneOf(['hello', 'world'], 'message');
mixed.notOneOf(['hello', 'world'], 'message');
mixed.when('isBig', {
    is: value => true,
    then: yup.number().min(5),
    otherwise: yup.number().min(0)
});
mixed.when('isBig', {
    is: true,
    then: yup.number().min(5),
    otherwise: yup.number().min(0)
}).when('$other', (value: any, schema: MixedSchema) => value === 4 ? schema.required() : schema);
// tslint:disable-next-line:no-invalid-template-strings
mixed.test('is-jimmy', '${path} is not Jimmy', value => value === 'jimmy');
mixed.test({
開發者ID:Dru89,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:yup-tests.ts

示例2:

    .then(value => value);
mixed.validateSyncAt("path", {}, { strict: true, context: {} });
mixed.isValid(undefined, (valid: true) => true);
mixed.isValid({ hello: "world" }).then(valid => valid);
mixed.cast({});
mixed.isType("hello");
mixed.strict(true);
mixed.strip(true);
mixed.withMutation(schema => {});
mixed.default({ number: 5 });
mixed.default(() => ({ number: 5 }));
mixed.default();
mixed.nullable(true);
mixed.required();
mixed.notRequired(); // $ExpectType MixedSchema
mixed.typeError("type error");
mixed.oneOf(["hello", "world"], "message");
mixed.notOneOf(["hello", "world"], "message");
mixed.when("isBig", {
    is: value => true,
    then: yup.number().min(5),
    otherwise: yup.number().min(0)
});
mixed
    .when("isBig", {
        is: true,
        then: yup.number().min(5),
        otherwise: yup.number().min(0)
    })
    .when(
        "$other",
開發者ID:j-f1,項目名稱:forked-DefinitelyTyped,代碼行數:31,代碼來源:yup-tests.ts

示例3:

mixed.isValid(undefined, (valid: true) => true);
mixed.isValid({ hello: "world" }).then(valid => valid);
mixed.cast({});
mixed.isType("hello");
mixed.strict(true);
mixed.strip(true);
mixed.withMutation(schema => {});
mixed.default({ number: 5 });
mixed.default(() => ({ number: 5 }));
mixed.default();
mixed.nullable(true);
mixed.required();
mixed.required('Foo');
mixed.required(() => 'Foo');
mixed.notRequired(); // $ExpectType MixedSchema
mixed.typeError("type error");
mixed.typeError(() => "type error");
mixed.oneOf(["hello", "world"], "message");
mixed.oneOf(["hello", "world"], () => "message");
mixed.notOneOf(["hello", "world"], "message");
mixed.notOneOf(["hello", "world"], () => "message");
mixed.when("isBig", {
    is: value => true,
    then: yup.number().min(5),
    otherwise: yup.number().min(0)
});
mixed
    .when("isBig", {
        is: true,
        then: yup.number().min(5),
        otherwise: yup.number().min(0)
開發者ID:christophercr,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:yup-tests.ts


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