使用带有反应原生的tcomb-form-native库 - 我将keyboardType设置为email-address.如何在表单中添加正则表达式或电子邮件验证程序?我是否必须在提交函数上执行此操作(并抛出一个特殊错误?)或者是否可以使用库设置正则表达式验证字段?
我注意到tcomb-validation https://github.com/gcanti/tcomb-validationlibrary有一个RegExp类型字段 - 但我没有看到任何如何使用它的例子.显示的示例似乎测试字段是否是正则表达式模式,这是一个令人困惑的用例,因为您通常希望针对正则表达式模式测试字段,而不是将正则表达式模式输入字段.
我想在react native中禁用日期选择器控件中的某些日期.我正在使用"日期选择器Android"和"日期选择器IOS",如果有人有任何替代解决方案吗?
这个案子我将实施到我的项目:如何在未来的每周禁用周末日???
我尝试在github https://github.com/gcanti/tcomb-form-native/中控制"tcomb-form-native",但我在这个控件中找不到我需要的东西
.
谢谢
如何confirmPassword使用tcomb-form-native库验证我的字段?
电子邮件和密码字段非常简单,我不知道如何比较模型中另一个字段的现有值.
这是我的代码.
const Email = t.refinement(t.String, (email) => {
const reg = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
return reg.test(email);
});
const Password = t.refinement(t.String, (password) => {
const reg = /^(?=\S+$).{8,}$/;
return reg.test(password);
});
const RegistrationData = t.struct({
email: Email,
password: Password,
confirmPassword: t.String // Need some equality check
});
Run Code Online (Sandbox Code Playgroud)
我已经调查了文档https://github.com/gcanti/tcomb-form-native#disable-a-field-based-on-another-fields-value但我无法理解它.