overleaf/services/web/public/coffee/ide/directives/validFile.coffee

13 lines
329 B
CoffeeScript
Raw Normal View History

2018-02-05 11:56:52 -05:00
define [
"base"
], (App) ->
App.directive "validFile", () ->
return {
require: 'ngModel'
link: (scope, element, attrs, ngModelCtrl) ->
ngModelCtrl.$validators.validFile = (modelValue) ->
validFileRegex = /^[^\*\/]*$/ # Don't allow * and /
isValid = modelValue.match validFileRegex
return isValid
}