Skip to content

Commit

Permalink
Use light collection for validations. Remove consoles. Fix email regex
Browse files Browse the repository at this point in the history
  • Loading branch information
javierbrea committed Feb 10, 2019
1 parent b365c46 commit c247980
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
6 changes: 1 addition & 5 deletions src/data-sources/users/collection.js
Expand Up @@ -63,11 +63,7 @@ const exactSearchBy = (usersResults, { email, name }) => {
});
};

export const usersCollectionExactFiltered = new Selector(
usersCollectionWithExtraData,
exactSearchBy,
[]
);
export const usersCollectionExactFiltered = new Selector(usersCollection, exactSearchBy, []);

const searchBy = (usersResults, { search, showSystem }) => {
return usersResults.filter(user => {
Expand Down
2 changes: 1 addition & 1 deletion src/data-sources/users/model.js
Expand Up @@ -8,7 +8,7 @@ import { userAvatar, byEmailFilter } from "./avatar";

const NAME_REGEX = /^[a-z0-9_.-]*$/;

const EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
const EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)+$/;

export const isValidUserName = name => name.length > 4 && NAME_REGEX.test(name);

Expand Down
12 changes: 3 additions & 9 deletions src/modules/users/views/helpers.js
@@ -1,18 +1,12 @@
import { usersCollectionExactFiltered } from "src/data-sources/users";

export const isUserNameRepeated = name => {
console.log("VALIDATING!!");
return usersCollectionExactFiltered
export const isUserNameRepeated = name =>
usersCollectionExactFiltered
.filter({
name
})
.read()
.then(results => {
console.log("RESULTS");
console.log(results);
return results.length > 0;
});
};
.then(results => results.length > 0);

export const isUserEmailRepeated = email =>
usersCollectionExactFiltered
Expand Down

0 comments on commit c247980

Please sign in to comment.