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

Function loadFields

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

Source from the content-addressed store, hash-verified

21}
22
23export const loadFields = (vm, schema) => {
24 if (!schema || schema.visible === false) {
25 return
26 }
27
28 switch (schema.type) {
29 case 'object':
30 for (let key in schema.properties) {
31 schema.properties[key].name = key
32
33 if (schema.required) {
34 for (let field of schema.required) {
35 if (schema.properties[field]) {
36 schema.properties[field].required = true
37 }
38 }
39 }
40
41 loadFields(vm, schema.properties[key])
42 }
43 break
44
45 case 'boolean':
46 vm.fields.push(parseBoolean(vm, schema))
47 break
48
49 case 'array':
50 vm.fields.push(parseArray(vm, schema))
51 break
52
53 case 'integer':
54 case 'number':
55 case 'string':
56 for (let keyword of ARRAY_KEYWORDS) {
57 if (schema.hasOwnProperty(keyword)) {
58 schema.items = {
59 type: schema.type,
60 enum: schema[keyword]
61 }
62 vm.fields.push(parseArray(vm, schema))
63 return
64 }
65 }
66 vm.fields.push(parseString(vm, schema))
67 break
68 }
69}
70
71export const parseBoolean = (vm, schema) => {
72 let field = schema.attrs || {}

Callers

nothing calls this directly

Calls 3

parseBooleanFunction · 0.85
parseArrayFunction · 0.85
parseStringFunction · 0.85

Tested by

no test coverage detected