首页 > 其他分享 >ant design的form的validate需要注意的点

ant design的form的validate需要注意的点

时间:2023-10-16 17:33:59浏览次数:31  
标签:form value ant design validate password

title: ant design的form的validate需要注意的点
date: 2023-10-16
author: KazooTTT
tags:
  - ant design
published: true

ant design的form的validate需要注意的点

<Form.Item
	name="confirm"
	label="Confirm Password"
	dependencies={['password']}
	hasFeedback
	rules={[
	  {
		required: true,
		message: 'Please confirm your password!',
	  },
	  ({ getFieldValue }) => ({
		validator(_, value) {
		  if (!value || getFieldValue('password') === value) {
			return Promise.resolve();
		  }
		  return Promise.reject(new Error('The new password that you entered do not match!'));
		},
	  }),
	]}
>	
	<Input.Password />
</Form.Item>

需要注意一下,即使rule中存在

	  {
		required: true,
		message: 'Please confirm your password!',
	  },

在后面的自定义校验(validator)中,也需要对value进行判断是否非空。
否则容易抛出其他的异常。

标签:form,value,ant,design,validate,password
From: https://www.cnblogs.com/KazooTTT/p/17767883.html

相关文章

  • pyspark 常用Transform算子
    frompysparkimportSparkConf,SparkContextconf=SparkConf().setAppName("test_SamShare").setMaster("local[4]")sc=SparkContext(conf=conf)#1.map对每一个元素进行一个映射rdd=sc.parallelize(range(1,11),4)rdd_map=rdd.map(lambdax:x*2......
  • Transformer
    自注意力机制(self-attention)一堆向量asetofvector:词语、图(每个节点可以看作一个向量)一对一:SequenceLabelingself-attention会吃一整个sequence的咨询全连接是定长的,attention是不定长的α计算关联性(自己也得和自己计算关联性)过程:b1b2b3b4是一致同时计算......
  • ABC202E Count Descendants
    ABC202ECountDescendants线段树合并模板题。每次询问就是给定有序数对\((u,d)\),求有根树\(T\)上,点\(u\)的子树内有多少点\(v\),使得\(v\)的深度恰好等于\(d+1\)。定义根节点深度为\(1\)。考虑对每一个点开一个长度为\(n\)(因为\(T\)的最大深度为\(n\))的数组......
  • terraform对应的云原生服务
    如果您已经对Terraform了如指掌,并期望自己的IaC技能有进一步提升的话,这篇文章很适合您!在本文中,我们将分享一些Terraform的高级使用技巧。从使用模块(module)、工作区(workspace)到管理远程状态存储、自定义provider等技巧,帮助您轻松、高效地管理基础设施。无论您管理的是小型网......
  • sra format SRA文件的格式
    http://www.ebi.ac.uk/ena/about/sra_formatReadmetadataformatMetadataisrepresentedusingXMLdocuments.FordetailedinformationaboutthemetadataXMLspleaserefertoSRAXML1.5metadataformat.ForexampleshowtopreparetheXMLspleasereferto......
  • 论文精读:用于少样本图像识别的语义提示(Semantic Prompt for Few-Shot Image Recogniti
    原文连接:SemanticPromptforFew-ShotImageRecognitionAbstract在小样本学习中(Few-shotLearning,FSL)中,有通过利用额外的语义信息,如类名的文本Embedding,通过将语义原型与视觉原型相结合来解决样本稀少的问题。但这种方法可能会遇到稀有样本中学到噪声特征导致收益有限。在这......
  • Epoque: Practical End-to-End Verifiable Post-Quantum-Secure E-Voting
    Todate,thesecurityofallpracticalend-to-endveri-fiablee-votingprotocolsrelieson“traditional”hardnessassumptions,suchasfactoringintegersorcomputingdiscretelogarithms.Withmoreandmorepowerfulquantumcomputersonthehorizon(see,......
  • ReentrantLock实现原理
    ReentrantLock是可重入的独占锁,只能有一个线程可以获取该锁,其它获取该锁的线程会被阻塞而被放入该锁的阻塞队列里面。看看ReentrantLock的加锁操作://创建非公平锁ReentrantLocklock=newReentrantLock();//获取锁操作lock.lock();try{//执行代码逻辑}catch(Except......
  • SimpleDateFormat线程安全性
    SimpleDateFormat线程安全性0结论SimpleDateFormat是线程不安全的。在JDK中关于SimpleDateFormat有这样一段描述:Dateformatsarenotsynchronized.Itisrecommendedtocreateseparateformatinstancesforeachthread.Ifmultiplethreadsaccessaformatconcurr......
  • Codeforces Round 677 (Div. 3) C. Dominant Piranha
    有\(n\)只水虎鱼在水族馆,大小为\(a_1,a_2,\cdots,a_n\)。一只水虎鱼被称为是主导的,当它可以吃掉水族馆中其他所有水虎鱼。其他水虎鱼不会有任何行动。一只水虎鱼只可以吃掉当前与它相邻并且体型严格比它小的水虎鱼。当大小为\(x\)的水虎鱼吃掉大小为\(y\)的水虎鱼时,......