Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

validators.js 1019 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  1. var builder = require('botbuilder');
  2. var PhoneRegex = new RegExp(/^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/);
  3. var EmailRegex = new RegExp(/[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/);
  4. var lib = new builder.Library('validators');
  5. lib.dialog('notes',
  6. builder.DialogAction.validatedPrompt(builder.PromptType.text, function (response) {
  7. return response && response.length <= 200;
  8. }));
  9. lib.dialog('phonenumber',
  10. builder.DialogAction.validatedPrompt(builder.PromptType.text, function (response) {
  11. return PhoneRegex.test(response);
  12. }));
  13. lib.dialog('email',
  14. builder.DialogAction.validatedPrompt(builder.PromptType.text, function (response) {
  15. return EmailRegex.test(response);
  16. }));
  17. // Export createLibrary() function
  18. module.exports.createLibrary = function () {
  19. return lib.clone();
  20. };
  21. module.exports.PhoneRegex = PhoneRegex;
  22. module.exports.EmailRegex = EmailRegex;
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...