Material theme input fields are broken with custom format validation
See original GitHub issueGeneral information
- json-editor version: 1.4.0-beta.0
- materialize/1.0.0/css/materialize.min.css
- materialize/1.0.0/js/materialize.min.js
Expected behavior
Input fields (string) are rendered as without format or built-in validation (e.g. minLength)
Actual behavior
Input fields are broken, Select generated from enums seems ok
Steps to reproduce the behavior
Attach custom validator with JS and use Material theme
Direct LINK
{
"type": "object",
"title": "Car",
"properties": {
"make": {
"type": "string",
"enum": [
"Toyota",
"BMW"
],
"format": "connectionString"
},
"model_custom": {
"type": "string",
"format": "connectionString"
},
"model": {
"type": "string",
"minLength": 1
}
}
}
JSONEditor.defaults.custom_validators.push(function (schema, value, path) {
var errors = [];
if (schema.format === "connectionString") {
if (!/^([^=;]+=[^=;]+)(;[^=;]+=[^=]+)*$/.test(value)) {
errors.push({
path: path,
property: 'format',
message: 'Connection string must be in the format "Server={value};Database={value};Trusted_Connection=yes;"'
});
}
}
return errors;
});
var editor = new JSONEditor(element, {
[...]
"theme": "materialize",
[...]
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:10
Top Results From Across the Web
Errors - Patterns - Material Design
Errors occur when an app fails to complete an expected action. Some examples of errors include: When user input is not understood; An...
Read more >Form Validation in React Material UI - YouTube
Form Validation in React Material UI.In this video, we discuss how to implement validation in React Material UI Form and how to insert...
Read more >Client-side form validation - Learn web development | MDN
Built-in form validation has better performance than JavaScript, but it is not as customizable as JavaScript validation.
Read more >Text Inputs - Materialize
The validate class leverages HTML5 validation and will add a valid and invalid class accordingly. If you don't want the Green and Red...
Read more >Bootstrap Input fields - examples & tutorial
Both elements are wrapped in .form-outline class which provides a material design look. Example label.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@lukzas Did the update I committed, solve your problem?
I think I have spotted the problem. In src/editors.string.js, the type is defined like this:
And the “HTML5 Input type” sets the type to the format. There should probably be a check for valid HTML5 input types here and a fallback to “text” type. I have committed an updated
src/editors/string.js
to the 2.x branch. Now it checks for valid HTML5 input types and fallback totext
type