Functional Weave
Code in TypeScript

auth.validate-login@1.0.0

vectors.json

2,254 bytes · view raw

[
  {"name": "a good form: the email is trimmed and its domain lower-cased for the lookup", "args": [" Ada@Example.COM ", "correct horse battery staple"], "expect": {"valid": true, "email": "Ada@example.com", "fields": {}}},
  {"name": "a pasted address with a tab and a trailing newline", "args": ["\tbob@EXAMPLE.org\n", "hunter2hunter2hunter2"], "expect": {"valid": true, "email": "bob@example.org", "fields": {}}},
  {"name": "a short password is not judged at login: it was set under older rules, and verifyPassword decides", "args": ["ada@example.com", "x"], "expect": {"valid": true, "email": "ada@example.com", "fields": {}}},
  {"name": "a password of spaces is not empty: passwords are never trimmed", "args": ["ada@example.com", "   "], "expect": {"valid": true, "email": "ada@example.com", "fields": {}}},
  {"name": "an empty password", "args": ["ada@example.com", ""], "expect": {"valid": false, "email": "ada@example.com", "fields": {"password": "Enter your password."}}},
  {"name": "both fields empty, email first", "args": ["", ""], "expect": {"valid": false, "email": null, "fields": {"email": "Enter your email address.", "password": "Enter your password."}}},
  {"name": "an email of only whitespace counts as empty", "args": [" \t ", "correct horse battery staple"], "expect": {"valid": false, "email": null, "fields": {"email": "Enter your email address."}}},
  {"name": "an email that is not an address", "args": ["ada@localhost", "correct horse battery staple"], "expect": {"valid": false, "email": null, "fields": {"email": "Enter a valid email address, like name@example.com."}}},
  {"name": "no @ at all", "args": ["ada.example.com", "correct horse battery staple"], "expect": {"valid": false, "email": null, "fields": {"email": "Enter a valid email address, like name@example.com."}}},
  {"name": "values that are not strings (a malformed JSON body) are treated as empty", "args": [42, null], "expect": {"valid": false, "email": null, "fields": {"email": "Enter your email address.", "password": "Enter your password."}}},
  {"name": "the local part keeps its case: only the domain is folded", "args": ["ADA@EXAMPLE.COM", "correct horse battery staple"], "expect": {"valid": true, "email": "ADA@example.com", "fields": {}}}
]