We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
可以让组件内置一些验证器:例如,IP 输入框
AbstractControl 新增了多个设置验证器的函数,可以在组件内部灵活的设置验证器,例如:
AbstractControl
<template> <input class="ip-input" :value="accessor.value" :disabled="accessor.disabled" @blur="onBlur" @input="onInput" /> </template> <script setup lang="ts"> import { watchEffect } from 'vue' import { type ValidatorFn, useAccessorAndControl } from '@idux/cdk/forms' defineProps<{ control?: string | number | (string | number)[] | object disabled?: boolean value?: string }>() const { accessor, control: controlRef } = useAccessorAndControl() const v4IPExp = /^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/ const ipValidator: ValidatorFn = (value: string) => { if (!value || v4IPExp.test(value)) { return undefined } return { ip: { message: 'IP address is not valid!' } } } watchEffect(() => { const currControl = controlRef.value if (currControl) { currControl.addValidators(ipValidator) } }) </script>
The text was updated successfully, but these errors were encountered:
You can make the component built -in some verification device: for example, the IP input box
Refer to the two token of Angular? -Ng_validators -NG_ASYNC_VALIDAM
Sorry, something went wrong.
feat(cdk:forms): abstractControl support add or remove the validators (…
60f9796
…#1055) fix #1037
danranVm
Successfully merging a pull request may close this issue.
What problem does this feature solve?
可以让组件内置一些验证器:例如,IP 输入框
What does the proposed API look like?
AbstractControl
新增了多个设置验证器的函数,可以在组件内部灵活的设置验证器,例如:The text was updated successfully, but these errors were encountered: