Skip to content
This repository has been archived by the owner on Dec 24, 2019. It is now read-only.

Add user info page / form #2

Open
timarney opened this issue Sep 4, 2019 · 1 comment
Open

Add user info page / form #2

timarney opened this issue Sep 4, 2019 · 1 comment

Comments

@timarney
Copy link
Member

timarney commented Sep 4, 2019

Collect name, email, phone number, Fake passport number

@timarney
Copy link
Member Author

timarney commented Sep 4, 2019

Use this for your schema.js

const isEmail = require("validator/lib/isEmail");
const isMobilePhone = require("validator/lib/isMobilePhone").default;

const Schema = {
  fullname: {
    isLength: {
      errorMessage: "errors.fullname.length",
      options: { min: 3, max: 200 }
    }
  },
  email: {
    custom: {
      options: (value, { req }) => {
        return isEmail(value);
      },
      errorMessage: "errors.email.valid"
    }
  },
  phone: {
    custom: {
      options: (value, { req }) => {
        return isMobilePhone(value);
      },
      errorMessage: "errors.phone.valid"
    }
  },
  passport_number: {
    isLength: {
      errorMessage: "errors.login.length",
      options: { min: 9, max: 9 }
    },
    isAlphanumeric: {
      errorMessage: "errors.login.alphanumeric"
    },
    customSanitizer: {
      options: value => {
        return value ? value.toUpperCase() : value;
      }
    }
  }
};

module.exports = {
  Schema
};

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant