Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified validators in few files according to new ValidateObject #13015

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion kolibri/plugins/learn/assets/src/views/ContentPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
import Modalities from 'kolibri-constants/Modalities';
import useUser from 'kolibri/composables/useUser';
import useSnackbar from 'kolibri/composables/useSnackbar';
import { validateObject } from 'kolibri/utils/objectSpecs';
import { setContentNodeProgress } from '../composables/useContentNodeProgress';
import useProgressTracking from '../composables/useProgressTracking';
import useContentLink from '../composables/useContentLink';
Expand Down Expand Up @@ -186,7 +187,50 @@
type: Object,
required: true,
validator(val) {
return val.kind && val.content_id;
return validateObject(val, {
kind: {
type: String,
required: true,
},
content_id: {
type: String,
required: true,
},
title: {
type: String,
required: true,
},
ancestors: {
type: Array,
required: false,
default: () => [],
},
files: {
type: Array,
required: false,
default: () => [],
},
options: {
type: Object,
required: false,
default: () => ({}),
},
available: {
type: Boolean,
required: false,
default: true,
},
duration: {
type: Number,
required: false,
default: 0,
},
assessmentmetadata: {
type: Object,
required: false,
default: () => ({}),
},
});
},
},
// only present when the content node is being viewed as part of lesson
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import { ContentLevels, AccessibilityCategories } from 'kolibri/constants';
import commonCoreStrings from 'kolibri/uiText/commonCoreStrings';
import { injectBaseSearch } from 'kolibri-common/composables/useBaseSearch';
import { validateObject } from 'kolibri/utils/objectSpecs';

export default {
name: 'SelectGroup',
Expand All @@ -70,8 +71,20 @@
type: Object,
required: true,
validator(value) {
const inputKeys = ['accessibility_labels', 'languages', 'grade_levels'];
return inputKeys.every(k => Object.prototype.hasOwnProperty.call(value, k));
return validateObject(value, {
accessibility_labels: {
type: Array,
required: true,
},
languages: {
type: Array,
required: true,
},
grade_levels: {
type: Array,
required: true,
},
});
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import commonSyncElements from 'kolibri-common/mixins/commonSyncElements';
import UsernameTextbox from 'kolibri-common/components/userAccounts/UsernameTextbox';
import PasswordTextbox from 'kolibri-common/components/userAccounts/PasswordTextbox';
import { validateObject } from 'kolibri/utils/objectSpecs';

export default {
name: 'FacilityAdminCredentialsForm',
Expand All @@ -61,7 +62,20 @@
type: Object,
required: true,
validator(val) {
return val.name && val.id && val.baseurl;
return validateObject(val, {
name: {
type: String,
required: true,
},
id: {
type: String,
required: true,
},
baseurl: {
type: String,
required: true,
},
});
},
},
facility: {
Expand Down
Loading