| 95 | |
| 96 | const generationFunctions = [] |
| 97 | function generateProperty (property, fn) { |
| 98 | const generationFunction = async function (level, parameters) { |
| 99 | const result = await fn(level, parameters) |
| 100 | if (property && result !== undefined) { |
| 101 | const { errors } = tv4.validateMultiple(result, levelSchema.properties[property]) |
| 102 | if (errors?.length) { |
| 103 | console.error(`Couldn't validate assignment of ${property}:`, result, `Validation error: ${errors}`) |
| 104 | return |
| 105 | } |
| 106 | level[property] = result |
| 107 | } |
| 108 | } |
| 109 | generationFunctions.push(generationFunction) |
| 110 | } |
| 111 | |
| 112 | // name: c.shortString() |
| 113 | generateProperty('name', function (level, parameters) { |