diff --git a/src/br/cep/cep.js b/src/br/cep/cep.js
index cc64914e..c39aef51 100644
--- a/src/br/cep/cep.js
+++ b/src/br/cep/cep.js
@@ -5,7 +5,7 @@ var cepMask = new StringMask('00000-000');
module.exports = maskFactory({
clearValue: function(rawValue) {
- return rawValue.replace(/[^0-9]/g, '').slice(0, 8);
+ return rawValue.toString().replace(/[^0-9]/g, '').slice(0, 8);
},
format: function(cleanValue) {
return (cepMask.apply(cleanValue) || '').replace(/[^0-9]$/, '');
diff --git a/src/br/cep/cep.test.js b/src/br/cep/cep.test.js
index 95f04322..04b6cc4d 100644
--- a/src/br/cep/cep.test.js
+++ b/src/br/cep/cep.test.js
@@ -20,6 +20,15 @@ describe('ui-br-cep-mask', function() {
expect(maskedModel.$formatters.length).toBe(model.$formatters.length + 1);
});
+ it('should convert number inputs to correct format', function() {
+ var input = TestUtil.compile('', {
+ model: 30112010
+ });
+
+ var model = input.controller('ngModel');
+ expect(model.$viewValue).toBe('30112-010');
+ });
+
it('should format initial model values', function() {
var input = TestUtil.compile('', {
model: '30112010'