verify.scm 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. (define-module (verify))
  2. (define-public (honey-pot-check post-data)
  3. ;; fixme wha does this work? or does it?
  4. (if (string= "" (car (assoc-ref post-data "hidden")))
  5. #t
  6. #f))
  7. (define-public (all-input-has-values post-data)
  8. (map (lambda (element)
  9. (let ([name (car element)]
  10. [value (car (cdr element))])
  11. (if (equal? "" value)
  12. #f
  13. #t)))))
  14. ;;this doesn't seem to work
  15. ;;(define-public email-regexp make-regexp "^[a-z0-9]+[a-z0-9]+\.[a-z]{2,}$" regexp/icase)
  16. (define-public email-regexp (make-regexp "[a-z0-9]+[a-z0-9]+\\.[a-z]{2,}$" regexp/icase))
  17. (define-public (email-is-valid email)
  18. (if (not (regexp-exec email-regexp email))
  19. #f
  20. #t))
  21. (define-public (verify-body body)
  22. (let* ([post-data (decode body)]
  23. [honey-pot? (honey-pot-check post-data)]
  24. [all-input-has-values? (all-input-has-values
  25. ;; (assoc-remove! "own-number")
  26. (assoc-remove! post-data "hidden"))]
  27. [email-is-valid? (email-is-valid (assoc-ref 'hidden post-data))]
  28. )
  29. (when email-is-valid?
  30. (display "email is valid!"))))