Skip to content

Commit

Permalink
Extendable validation schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Benek committed Aug 10, 2018
1 parent 19698d0 commit 807d64a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ build/config.json
core/build/config.json
theme.js
desktop.ini
*.extension.json
src/themes/catalog/resource/i18n.json
src/themes/default/resource/i18n.json
src/themes/theme-starter/resource/.i18n.json.icloud
Expand Down
4 changes: 3 additions & 1 deletion core/store/modules/order/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export default {
*/
placeOrder ({ commit }, order) {
const ajv = new Ajv()
const validate = ajv.compile(require('./order.schema.json'))
const orderSchema = require('./order.schema.json')
const orderSchemaExtension = require('./order.schema.extension.json')
const validate = ajv.compile(Object.assign(orderSchema, orderSchemaExtension))

const storeView = currentStoreView()
if (storeView.storeCode) {
Expand Down
1 change: 1 addition & 0 deletions core/store/modules/order/order.schema.extension.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 3 additions & 1 deletion core/store/modules/user/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ export default {
*/
update (context, userData) {
const ajv = new Ajv()
const validate = ajv.compile(require('./userProfile.schema.json'))
const userProfileSchema = require('./userProfile.schema.json')
const userProfileSchemaExtension = require('./userProfile.schema.extension.json')
const validate = ajv.compile(Object.assign(userProfileSchema, userProfileSchemaExtension))

if (!validate(userData)) { // schema validation of user profile data
EventBus.$emit('notification', {
Expand Down
1 change: 1 addition & 0 deletions core/store/modules/user/userProfile.schema.extension.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}

0 comments on commit 807d64a

Please sign in to comment.