Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. export const AdvancedTypes: { [key:string]: any} = {
  2. email: {
  3. // Binary type or primitive type
  4. binaryType : 'asciiString',
  5. // Initialization value. This value is used as default value
  6. init : '""',
  7. // Parse value. We should not do any extra decode operations with it
  8. parse : (value: string) => { return value; },
  9. // Also we should not do any encoding operations with it
  10. serialize : (value: string) => { return value; },
  11. // Typescript type
  12. tsType : 'string',
  13. // Validation function to valid value
  14. validate : (value: string) => {
  15. if (typeof value !== 'string'){
  16. return false;
  17. }
  18. if (value.trim() === '') {
  19. // Initialization value is "''", so we allow use empty string.
  20. return true;
  21. }
  22. const validationRegExp = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/gi;
  23. return validationRegExp.test(value);
  24. },
  25. }
  26. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement