mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Added name property to duplicate newsletter ValidationError (#14694)
refs https://github.com/TryGhost/Team/issues/1564 We need this property in the frontend to correctly handle the error
This commit is contained in:
parent
473ac3b5a4
commit
cf9231e77a
2 changed files with 12 additions and 6 deletions
|
@ -120,7 +120,10 @@ class NewslettersService {
|
|||
newsletter = await this.NewsletterModel.add(cleanedAttrs, options);
|
||||
} catch (error) {
|
||||
if (error.code && error.message.toLowerCase().indexOf('unique') !== -1) {
|
||||
throw new errors.ValidationError({message: tpl(messages.nameAlreadyExists)});
|
||||
throw new errors.ValidationError({
|
||||
message: tpl(messages.nameAlreadyExists),
|
||||
property: 'name'
|
||||
});
|
||||
}
|
||||
|
||||
throw error;
|
||||
|
@ -165,7 +168,10 @@ class NewslettersService {
|
|||
updatedNewsletter = await this.NewsletterModel.edit(cleanedAttrs, options);
|
||||
} catch (error) {
|
||||
if (error.code && error.message.toLowerCase().indexOf('unique') !== -1) {
|
||||
throw new errors.ValidationError({message: tpl(messages.nameAlreadyExists)});
|
||||
throw new errors.ValidationError({
|
||||
message: tpl(messages.nameAlreadyExists),
|
||||
property: 'name'
|
||||
});
|
||||
}
|
||||
|
||||
throw error;
|
||||
|
|
|
@ -911,7 +911,7 @@ Object {
|
|||
"help": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||
"message": "Validation error, cannot save newsletter.",
|
||||
"property": null,
|
||||
"property": "name",
|
||||
"type": "ValidationError",
|
||||
},
|
||||
],
|
||||
|
@ -922,7 +922,7 @@ exports[`Newsletters API Can't add multiple newsletters with same name 4: [heade
|
|||
Object {
|
||||
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||
"content-length": "251",
|
||||
"content-length": "253",
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||
"vary": "Origin, Accept-Encoding",
|
||||
|
@ -940,7 +940,7 @@ Object {
|
|||
"help": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||
"message": "Validation error, cannot edit newsletter.",
|
||||
"property": null,
|
||||
"property": "name",
|
||||
"type": "ValidationError",
|
||||
},
|
||||
],
|
||||
|
@ -951,7 +951,7 @@ exports[`Newsletters API Can't edit multiple newsletters to existing name 2: [he
|
|||
Object {
|
||||
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||
"content-length": "251",
|
||||
"content-length": "253",
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||
"vary": "Origin, Accept-Encoding",
|
||||
|
|
Loading…
Add table
Reference in a new issue