Total Complexity | 4 |
Complexity/F | 2 |
Lines of Code | 34 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | import _ from 'underscore'; |
||
|
|||
2 | import { |
||
3 | CellFormatter |
||
4 | } from './cell.js'; |
||
5 | /** |
||
6 | Simple email validation formatter. |
||
7 | |||
8 | @class Backgrid.EmailFormatter |
||
9 | @extends Backgrid.CellFormatter |
||
10 | @constructor |
||
11 | */ |
||
12 | var EmailFormatter = function () {}; |
||
13 | EmailFormatter.prototype = new CellFormatter(); |
||
14 | _.extend(EmailFormatter.prototype, { |
||
15 | /** |
||
16 | Return the input if it is a string that contains an '@' character and if |
||
17 | the strings before and after '@' are non-empty. If the input does not |
||
18 | validate, `undefined` is returned. |
||
19 | |||
20 | @member Backgrid.EmailFormatter |
||
21 | @param {*} formattedData |
||
22 | @param {Backbone.Model} model Used for more complicated formatting |
||
23 | @return {string|undefined} |
||
24 | */ |
||
25 | toRaw: function (formattedData, model) { |
||
26 | var parts = formattedData.trim().split("@"); |
||
27 | if (parts.length === 2 && _.all(parts)) { |
||
28 | return formattedData; |
||
29 | } |
||
30 | } |
||
31 | }); |
||
32 | export { |
||
33 | EmailFormatter |
||
34 | }; |
||
35 |