MCPcopy Create free account
hub / github.com/formschema/native / parseString

Function parseString

lib/parser.js:91–144  ·  view source on GitHub ↗
(vm, schema)

Source from the content-addressed store, hash-verified

89}
90
91export const parseString = (vm, schema) => {
92 let field = schema.attrs || {}
93
94 if (!field.type) {
95 switch (schema.type) {
96 case 'number':
97 case 'integer':
98 field.type = 'number'
99 break
100 default:
101 field.type = 'text'
102 }
103 }
104
105 if (schema.format) {
106 switch (schema.format) {
107 case 'email':
108 if (!field.type) {
109 field.type = 'email'
110 }
111 break
112 case 'uri':
113 if (!field.type) {
114 field.type = 'url'
115 }
116 break
117 case 'regex':
118 if (!field.type) {
119 field.type = 'text'
120 }
121
122 field.pattern = schema.format
123 break
124 }
125 }
126
127 setCommonFields(schema, field)
128
129 if (schema.name) {
130 field.name = schema.name
131
132 setFormValue(vm, field)
133 }
134
135 if (schema.minLength) {
136 field.minlength = schema.minLength
137 }
138
139 if (schema.maxLength) {
140 field.maxlength = schema.maxLength
141 }
142
143 return field
144}
145
146export const parseItems = (items) => {
147 return items.map((item) => {

Callers 1

loadFieldsFunction · 0.85

Calls 2

setCommonFieldsFunction · 0.85
setFormValueFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…