mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Refactored i18n out of redirects validation
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings - i18n is an old pattern we are getting rid of
This commit is contained in:
parent
2fc26bd80a
commit
d316d9fdec
1 changed files with 6 additions and 3 deletions
|
@ -1,7 +1,10 @@
|
|||
const _ = require('lodash');
|
||||
const i18n = require('../../../shared/i18n');
|
||||
const errors = require('@tryghost/errors');
|
||||
|
||||
const messages = {
|
||||
redirectsWrongFormat: 'Incorrect redirects file format.'
|
||||
};
|
||||
|
||||
/**
|
||||
* Redirects are file based at the moment, but they will live in the database in the future.
|
||||
* See V2 of https://github.com/TryGhost/Ghost/issues/7707.
|
||||
|
@ -9,7 +12,7 @@ const errors = require('@tryghost/errors');
|
|||
const validate = (redirects) => {
|
||||
if (!_.isArray(redirects)) {
|
||||
throw new errors.ValidationError({
|
||||
message: i18n.t('errors.utils.redirectsWrongFormat'),
|
||||
message: messages.redirectsWrongFormat,
|
||||
help: 'https://ghost.org/docs/themes/routing/#redirects'
|
||||
});
|
||||
}
|
||||
|
@ -17,7 +20,7 @@ const validate = (redirects) => {
|
|||
_.each(redirects, function (redirect) {
|
||||
if (!redirect.from || !redirect.to) {
|
||||
throw new errors.ValidationError({
|
||||
message: i18n.t('errors.utils.redirectsWrongFormat'),
|
||||
message: messages.redirectsWrongFormat,
|
||||
context: redirect,
|
||||
help: 'https://ghost.org/docs/themes/routing/#redirects'
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue