overleaf/services/web/public/coffee/ide/directives/validFile.coffee
2018-02-06 11:46:50 +00:00

12 lines
329 B
CoffeeScript

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
}