Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation to new root profile attributes #1657

Merged
merged 6 commits into from
Jul 11, 2019

Conversation

luisrudge
Copy link
Contributor

Changes

Add default validation for new root profile attributes

Testing

  • This change adds unit test coverage
  • This change adds integration test coverage
  • This change has been tested on the latest version of the platform/language

@luisrudge luisrudge added this to the v11.17.0 milestone Jun 13, 2019
@luisrudge luisrudge force-pushed the feature/new-fields-validation branch from a48ccbd to d5319a6 Compare June 13, 2019 18:17
@luisrudge luisrudge marked this pull request as ready for review June 26, 2019 18:59
@luisrudge luisrudge requested a review from a team June 26, 2019 18:59
src/field/index.js Show resolved Hide resolved
src/field/username.js Show resolved Hide resolved
support/index.html Outdated Show resolved Hide resolved
@luisrudge luisrudge requested a review from damieng June 27, 2019 14:21
damieng
damieng previously approved these changes Jul 9, 2019
@@ -3,8 +3,8 @@ import { validateEmail } from './email';
import { databaseConnection } from '../connection/database';
import trim from 'trim';

const DEFAULT_CONNECTION_VALIDATION = { username: { min: 1, max: 15 } };
const regExp = /^[a-zA-Z0-9_+\-.]+$/;
const DEFAULT_CONNECTION_VALIDATION = { username: { min: 1, max: 128 } };
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default didn't change, still 15 chars.

@@ -55,5 +55,5 @@ export function setUsername(m, str, usernameStyle = 'username', validateUsername
}

export function usernameLooksLikeEmail(str) {
return str.indexOf('@') > -1;
return str.indexOf('@') > -1 && str.indexOf('.') > -1;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please use a more robust email validation library?
Ideally, the same library used in the backend should be used in Lock:
https://github.com/validatorjs/validator.js#client-side-usage

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this validation is only for cases that the browser doesn't support html5 validation, since we use that by default. we're not adding +20kb just to do email validation 😬

invalidChars.forEach(i => expectToFailWith(`aa${i}`));
});
it('accepts letters, numbers, `_`, `-`, `+` and `.`', () => {
const validChars = `_-+.`.split('');
const validChars = `_+-.!#$'^\`~@`.split('');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Update test title with new chars

@luisrudge luisrudge merged commit 305f533 into master Jul 11, 2019
@luisrudge luisrudge deleted the feature/new-fields-validation branch July 11, 2019 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants