Skip to content

Commit

Permalink
jsdoc openapiv3schema validator function
Browse files Browse the repository at this point in the history
  • Loading branch information
mantis-toboggan-md committed Dec 13, 2023
1 parent 084543d commit d96ff77
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 28 deletions.
13 changes: 1 addition & 12 deletions pkg/capi/components/CCVariables/Variable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import LabeledSelect from '@shell/components/form/LabeledSelect';
import formRulesGenerator, { Validator } from '@shell/utils/validators/formRules';
import type { ClusterClassVariable } from '../../types/clusterClass';
import openAPIV3SchemaValidators from '../../util/validators';
// object, array, string, integer, number or boolean.
import { openAPIV3SchemaValidators } from '../../util/validators';
export default defineComponent({
name: 'CCVariable',
Expand Down Expand Up @@ -68,15 +66,6 @@ export default defineComponent({
return out;
},
componentWidths() {
return {
LabeledSelect: 'span-3',
LabeledInput: 'span-3',
Checkbox: 'span-3',
ArrayList: 'span-6'
};
},
schema() {
return this.variable?.schema?.openAPIV3Schema;
},
Expand Down
26 changes: 10 additions & 16 deletions pkg/capi/util/validators.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
// * format (string)
// * exclusiveMinimum (integer/number)
// * exclusiveMaximum (integer/number)
// * maxItems (array)
// * maxLength (string)
// * maximum (integer/number)
// * minItems (array)
// * minLength (string)
// * minimum (integer/number)
// * pattern (string)
// * uniqueItems (array)
// * required (object)

import { Validator, ValidationOptions } from '@shell/utils/validators/formRules';
import { Translation } from '@shell/types/t';

export default function(t: Translation, { key = 'Value' }: ValidationOptions, openAPIV3Schema: any): Validator[] {
/**
*
* @param t this.$store.getters[i18n/t]
* @param param1 param1.key should be the (already localized) label of the field being validated
* @param openAPIV3Schema cluster class variable schema.openapiv3schema
*
* @returns an array of validator functions that work with the form-validation mixin. These can be supplied to any component wth the labeled-form-element mixin using the rules prop
*/
export const openAPIV3SchemaValidators = function(t: Translation, { key = 'Value' }: ValidationOptions, openAPIV3Schema: any): Validator[] {
const {
exclusiveMinimum,
exclusiveMaximum,
Expand Down Expand Up @@ -73,4 +67,4 @@ export default function(t: Translation, { key = 'Value' }: ValidationOptions, op
}

return out;
}
};

0 comments on commit d96ff77

Please sign in to comment.