Merge branch 'master' into graphql-use-playground

This commit is contained in:
Jim LAURIE 2018-05-15 18:15:15 +02:00 committed by GitHub
commit c5d11e270b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 8 deletions

View File

@ -1,4 +1,4 @@
import { get, filter, isNumber, size, split, isEmpty, has, map, concat } from 'lodash';
import { get, filter, isNumber, size, split, isEmpty, has, map, concat, includes } from 'lodash';
export default function checkAttributeValidations(errors) {
@ -36,6 +36,34 @@ export default function checkAttributeValidations(errors) {
formErrors.push({ name: 'params.key', errors: [{ id: 'content-type-builder.error.attribute.sameKeyAndName' }]});
}
const reserved = [
'id',
'set',
'value',
'emit',
'on',
'once',
'listeners',
'removeListener',
'collection',
'db',
'isModified',
'isNew',
'get',
'modelName',
'save',
'schema',
'toObject',
'validate',
'remove',
'_pres',
'_posts',
];
if (includes(reserved, get(this.props.modifiedDataAttribute, 'name'))) {
formErrors.push({ name: 'name', errors: [{ id: 'content-type-builder.error.attribute.forbidden' }]});
}
return formErrors;
}

View File

@ -43,6 +43,7 @@
"error.attribute.key.taken": "This value already exists",
"error.attribute.sameKeyAndName": "Can't be equal",
"error.validation.minSupMax": "Can't be superior",
"error.attribute.forbidden": "This attribute name is reserved",
"form.attribute.item.textarea.name": "Name",
"form.attribute.item.number.name": "Name",

View File

@ -44,6 +44,7 @@
"error.attribute.key.taken": "Cette valeur existe déjà",
"error.attribute.sameKeyAndName": "Ne peuvent pas être égaux",
"error.validation.minSupMax": "Ne peut pas être plus grand",
"error.attribute.forbidden": "Cet attribut est réservé",
"form.attribute.item.textarea.name": "Nom",
"form.attribute.item.date.name": "Nom",

View File

@ -544,14 +544,9 @@ module.exports = {
if (association.type === 'model') {
params.id = obj[association.alias];
} else {
// Get attribute.
const attr = association.plugin ?
strapi.plugins[association.plugin].models[params.model].attributes[association.via]:
strapi.models[params.model].attributes[association.via];
// Get refering model.
const ref = attr.plugin ?
strapi.plugins[attr.plugin].models[params.model]:
const ref = association.plugin ?
strapi.plugins[association.plugin].models[params.model]:
strapi.models[params.model];
// Apply optional arguments to make more precise nested request.