GithubHelp home page GithubHelp logo

nikitazh1812 / js_check_the_form Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mate-academy/js_check_the_form

0.0 0.0 0.0 249 KB

License: GNU General Public License v3.0

JavaScript 100.00%

js_check_the_form's Introduction

Write tests for the function validateRegisterForm, which takes two strings password and email, and returns an object with a response that contain status code and message.

If all entered data is valid object contains status code 200 and message Email and password are valid..
If entered email is invalid object contains status code 422 and message Email is invalid..
If entered password is invalid object contains status code 422 and message Password is invalid..
If entered password and email are invalid object contains status code 500 and message Password and email are invalid..

Requirements for the valid password:

  • accepts letters Aa-Zz, Aa-ะฏั;
  • at least 8 characters inclusive;
  • maximum 16 characters inclusive;
  • contains at least 1 digit, 1 special character, 1 uppercase letter.

Requirements for the valid email:

  • English letters(Aa-Zz).
  • Digits.
  • Characters: ! # $ % & ' * + - / = ? ^ _ ` { | } ~
  • Character . ( period, dot or fullstop) provided that it is not the first or last character and it will not come one after the other.
  • @ is required
  • top Level domain can not start with dot .
  • top level domain can not start with dot .
  • an email should not be start with .
  • double dots are not allowed

The function does not check the uniqueness of the email and length of email (it made by another functions).

Examples:

validateRegisterForm('[email protected]', 'P@ssword1!') === { code: 200, message: 'Email and password are valid.', }
validateRegisterForm('[email protected]', 'P@ssword') === { code: 422, message: 'Password is invalid.', }
validateRegisterForm('test@com', 'P@ssword1') === { code: 422, message: 'Email is invalid.', }
validateRegisterForm('test@com', 'ssword1') === { code: 500, message: 'Password and email are invalid.', }

Hint: focus on the most priority and realistic cases, do not focus on edge cases.

Guideline

Read more about Jest expectations

js_check_the_form's People

Contributors

ibrianwarner avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.