Ghost/ghost/admin/app/validators/slack-integration.js
Kevin Ansfield 042aecb7f6 Switch from embor-browserify to ember-auto-import
no issue
- minor reduction in build size. Before/after:
  - `vendor.min.js 3.32 MB (710.66 KB gzipped)`
  - `vendor.min.js 3.29 MB (706 KB gzipped)`
2019-01-22 13:09:38 +00:00

25 lines
679 B
JavaScript

import BaseValidator from './base';
import validator from 'validator';
import {isBlank} from '@ember/utils';
export default BaseValidator.create({
properties: ['url'],
url(model) {
let url = model.get('url');
let hasValidated = model.get('hasValidated');
// eslint-disable-next-line camelcase
if (!isBlank(url) && !validator.isURL(url, {require_protocol: true})) {
model.get('errors').add(
'url',
'The URL must be in a format like https://hooks.slack.com/services/<your personal key>'
);
this.invalidate();
}
hasValidated.addObject('url');
}
});