mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-09 01:44:19 +01:00
resolving expressions only of type is string
This commit is contained in:
parent
330ea158b0
commit
fb53386ce2
2 changed files with 8 additions and 3 deletions
|
|
@ -26,7 +26,7 @@ export default function initializeBySchema(schema, context) {
|
|||
} else if (md.type === 'object') {
|
||||
val = initializeBySchema(md.schema, context);
|
||||
} else if (md.type === 'number') {
|
||||
val = md.defaultValue + '';
|
||||
val = md.defaultValue;
|
||||
} else {
|
||||
val = md.defaultValue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,14 +10,19 @@ export default function materializeParams(services, params, schema, result, erro
|
|||
continue;
|
||||
}
|
||||
let value = params[field];
|
||||
if (value === undefined) {
|
||||
if (value === undefined || value === null || value === '') {
|
||||
if (!md.optional) {
|
||||
errors.push({path: [...parentPath, field], message: 'required'});
|
||||
}
|
||||
} else {
|
||||
if (md.type === 'number') {
|
||||
try {
|
||||
value = services.expressions.evaluateExpression(value);
|
||||
const valueType = typeof value;
|
||||
if (valueType === 'string') {
|
||||
value = services.expressions.evaluateExpression(value);
|
||||
} else if (valueType !== 'number') {
|
||||
errors.push({path: [...parentPath, field], message: 'invalid value'});
|
||||
}
|
||||
} catch (e) {
|
||||
errors.push({path: [...parentPath, field], message: 'unable to evaluate expression'});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue