Check for empty version number

This commit is contained in:
Tony Garnock-Jones 2014-11-08 19:44:38 -05:00
parent 4070a9f0ba
commit e9f9b6a303
2 changed files with 10 additions and 8 deletions

View File

@ -13,8 +13,6 @@ you should be able to specify git repos over http/https
you should be able to specify subdirs in git repos
you should check the existence of repos/github repos/urls/etc via XHR
don't let people enter blank version numbers
Much more input validation is needed
## Design possibilities

View File

@ -908,12 +908,16 @@
;; Right up there with "parse error".
draft))]
["add_version"
(if (assoc new_version (draft-package-versions draft))
(package-form (format "Could not add version ~a, as it already exists." new_version)
draft)
(package-form #f (struct-copy draft-package draft
[versions (cons (list new_version default-empty-source-url)
(draft-package-versions draft))])))]
(cond
[(equal? (string-trim new_version) "")
(package-form "Please enter a version number to add." draft)]
[(assoc new_version (draft-package-versions draft))
(package-form (format "Could not add version ~a, as it already exists." new_version)
draft)]
[else
(package-form #f (struct-copy draft-package draft
[versions (cons (list new_version default-empty-source-url)
(draft-package-versions draft))]))])]
[(regexp #px"^version__(.*)__delete$" (list _ version))
(package-form #f (struct-copy draft-package draft
[versions (filter (lambda (v)