Skip to content

Commit

Permalink
fix: fix allowed types typing (#343)
Browse files Browse the repository at this point in the history
* fix: fix allowed types typing

* fix: added number as allowed input and fixed other types

* fix: make the optionid optional because of wrapper

* fix: expand PrefabComponentOptionCategory
  • Loading branch information
sventruschel authored Sep 7, 2022
1 parent 217f3e8 commit c9ad080
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ export type PrefabComponentOptionCategory = {
label: string;
extended?: boolean;
members: string[];
condition?: {
type: string;
option: string;
comparator: string;
value: string | boolean | number;
};
};

export type PrefabComponentOption = PrefabComponentOptionBase &
Expand Down
2 changes: 1 addition & 1 deletion src/validations/prefab/componentOption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const optionConfigurationSchemaBase = {
allowedInput: Joi.array().items(
Joi.object({
name: Joi.string().allow(''),
value: Joi.any(),
value: Joi.alternatives().try(Joi.boolean(), Joi.string(), Joi.number()),
}),
),
allowedTypes: Joi.array().items(Joi.string()),
Expand Down
9 changes: 8 additions & 1 deletion src/validations/prefab/linkedOption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ import { COMPARATORS, CONDITION_TYPE, CONFIGURATION_AS } from '../constants';
const linkedOptionValueSchema = Joi.object({
ref: Joi.object({
componentId: Joi.string().required(),
optionId: Joi.string().required(),
optionId: Joi.string().optional(),
}),
});

export const linkedOptionConfigurationSchema = Joi.object({
as: Joi.string().valid(...CONFIGURATION_AS),
dataType: Joi.string(),
allowedInput: Joi.array().items(
Joi.object({
name: Joi.string(),
value: Joi.alternatives().try(Joi.boolean(), Joi.string(), Joi.number()),
}),
),
condition: Joi.object({
type: Joi.string().valid(...CONDITION_TYPE),
option: Joi.string(),
Expand Down

0 comments on commit c9ad080

Please sign in to comment.