对于想了解[Vuewarn]:Invalidprop:customvalidatorcheckfailedforprop"type".的读者,本文将是一篇不可错过的文章,并且为您提供关于angular
对于想了解[Vue warn]: Invalid prop: custom validator check failed for prop "type".的读者,本文将是一篇不可错过的文章,并且为您提供关于angular – Async Validator Throw Expected validator返回Promise或Observable、Cannot convert value of type [java.lang.String] to required type [java.util.Date] for property ...、com.intellij.uiDesigner.propertyInspector.properties.CustomCreateProperty的实例源码、com.intellij.uiDesigner.propertyInspector.properties.IdentifierValidator的实例源码的有价值信息。
本文目录一览:- [Vue warn]: Invalid prop: custom validator check failed for prop "type".
- angular – Async Validator Throw Expected validator返回Promise或Observable
- Cannot convert value of type [java.lang.String] to required type [java.util.Date] for property ...
- com.intellij.uiDesigner.propertyInspector.properties.CustomCreateProperty的实例源码
- com.intellij.uiDesigner.propertyInspector.properties.IdentifierValidator的实例源码
[Vue warn]: Invalid prop: custom validator check failed for prop "type".
[Vue warn]: Invalid prop: custom validator check failed for prop "type".
found in
---> <Button>
<Modal>
<SubjectArrange> at src\views\teaching\subject\subjectArrange.vue
<App> at src\views\layout\App.vue
<App> at src\App.vue
<Root>
错误提示:在 model 之下的 button 里有错误,type 类型无法准确插入。
最后排查出来的结果是, 有一个 button 的 type 多打了一个空格!!!
1 <Button type="primary ">确认</Button>
2 改成下面的就可以了
3 <Button type="primary">确认</Button>
angular – Async Validator Throw Expected validator返回Promise或Observable
Expected validator to return Promise or Observable.
这是我的代码.
呼叫验证器:
cPass: ['',Validators.compose([ Validators.required,Validators.maxLength(32),Validators.minLength(10) ]),this.validPassword.bind(this) ]
自定义验证功能:
validPassword(control: AbstractControl) { const isEqual = Observable.of(this.password == control.value); return isEqual ? { valid : true } : null; }
Expected validator to return Promise or Observable.
你在函数中返回对象| null.
只需将其更改为:
validPassword(control: AbstractControl) { return observableOf('12345678910' === control.value).pipe( map(result => result ? { invalid: true } : null) ); }
STABKBLITZ DEMO
Cannot convert value of type [java.lang.String] to required type [java.util.Date] for property ...
异常信息:
04-Aug-2014 15:49:27.894 SEVERE [http-apr-8080-exec-5] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [cms] in context with path [/cms] threw exception [Request processing failed; nested exception is org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 6 errors Field error in object ''carContractSearchBox'' on field ''createEndDate'': rejected value []; codes [typeMismatch.carContractSearchBox.createEndDate,typeMismatch.createEndDate,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [carContractSearchBox.createEndDate,createEndDate]; arguments []; default message [createEndDate]]; default message [Failed to convert property value of type ''java.lang.String'' to required type ''java.util.Date'' for property ''createEndDate''; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [java.util.Date] for property ''createEndDate'': no matching editors or conversion strategy found]
先说明一下,我们的项目使用的是 Spring MVC。相应的功能是一个简单的 form 表单查询功能,里面有一些日期字段的查询。
相应的解决办法为:
在对应的 controller 中增加属性编辑器:
@InitBinder
protected void initBinder(WebDataBinder binder) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); }
注意这块的 new CustomDateEditor(dateFormat, true)
中的 true,查看 CustomDateEditor
源码可以看到:
/**
* Create a new CustomDateEditor instance, using the given DateFormat
* for parsing and rendering.
* <p>The "allowEmpty" parameter states if an empty String should
* be allowed for parsing, i.e. get interpreted as null value.
* Otherwise, an IllegalArgumentException gets thrown in that case.
* @param dateFormat DateFormat to use for parsing and rendering
* @param allowEmpty if empty strings should be allowed
*/
public CustomDateEditor(DateFormat dateFormat, boolean allowEmpty) { this.dateFormat = dateFormat; this.allowEmpty = allowEmpty; this.exactDateLength = -1; }
当 allowEmpty
字段为 true 的时候 form 表单传递的值可以为空。否则会出现 ""
字符串解析为 date 报错。
com.intellij.uiDesigner.propertyInspector.properties.CustomCreateProperty的实例源码
public void run() { CustomCreateProperty.generateCreateComponentsMethod(myClass); }
public void run() { CustomCreateProperty.generateCreateComponentsMethod(myClass); }
public void run() { CustomCreateProperty.generateCreateComponentsMethod(myClass); }
com.intellij.uiDesigner.propertyInspector.properties.IdentifierValidator的实例源码
public static void groupButtons(final GuiEditor editor,final List<RadComponent> selectedComponents) { if (!editor.ensureEditable()) return; String groupName = Messages.showInputDialog(editor.getProject(),UIDesignerBundle.message("group.buttons.name.prompt"),UIDesignerBundle.message("group.buttons.title"),Messages.getQuestionIcon(),editor.getRootContainer().suggestGroupName(),new IdentifierValidator(editor.getProject())); if (groupName == null) return; RadRootContainer rootContainer = editor.getRootContainer(); RadButtonGroup group = rootContainer.createGroup(groupName); for(RadComponent component: selectedComponents) { rootContainer.setGroupForComponent(component,group); } editor.refreshAndSave(true); }
public static void groupButtons(final GuiEditor editor,group); } editor.refreshAndSave(true); }
public static void groupButtons(final GuiEditor editor,group); } editor.refreshAndSave(true); }
今天的关于[Vue warn]: Invalid prop: custom validator check failed for prop "type".的分享已经结束,谢谢您的关注,如果想了解更多关于angular – Async Validator Throw Expected validator返回Promise或Observable、Cannot convert value of type [java.lang.String] to required type [java.util.Date] for property ...、com.intellij.uiDesigner.propertyInspector.properties.CustomCreateProperty的实例源码、com.intellij.uiDesigner.propertyInspector.properties.IdentifierValidator的实例源码的相关知识,请在本站进行查询。
本文标签: