Ghost/ghost/admin/app/validators/slack-integration.js
Austin Burdine 2a55c5767f Bower => NPM (#972)
no issue

- Convert validator to an npm dependency
  - clean up validator imports
  - fix validator function imports
  - remove unused validator extensions
- Convert devicejs to an npm dependency
- Convert remaining used bower deps to npm deps
- 🔥 Remove bower & unused bower dependencies
- remove globals imports in favor of direct module imports where possible
2018-03-19 17:56:09 +00:00

25 lines
683 B
JavaScript

import BaseValidator from './base';
import validator from 'npm: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');
}
});