Files
DiceCloud/app/imports/api/properties/ClassLevels.js
2022-10-09 16:01:36 +02:00

49 lines
1.3 KiB
JavaScript

import SimpleSchema from 'simpl-schema';
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
import createPropertySchema from '/imports/api/properties/subSchemas/createPropertySchema.js';
const ClassLevelSchema = createPropertySchema({
name: {
type: String,
optional: true,
max: STORAGE_LIMITS.name,
},
description: {
type: 'inlineCalculationFieldToCompute',
optional: true,
},
// The name of this class level's variable
variableName: {
type: String,
min: 2,
regEx: VARIABLE_NAME_REGEX,
max: STORAGE_LIMITS.variableName,
optional: true,
},
level: {
type: SimpleSchema.Integer,
defaultValue: 1,
max: STORAGE_LIMITS.levelMax,
},
// Filters out of UI if condition isn't met, but isn't otherwise enforced
slotFillerCondition: {
type: String,
optional: true,
max: STORAGE_LIMITS.calculation,
},
});
const ComputedOnlyClassLevelSchema = createPropertySchema({
description: {
type: 'computedOnlyInlineCalculationField',
optional: true,
},
});
const ComputedClassLevelSchema = new SimpleSchema()
.extend(ComputedOnlyClassLevelSchema)
.extend(ClassLevelSchema);
export { ClassLevelSchema, ComputedOnlyClassLevelSchema, ComputedClassLevelSchema };