-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from bigcommerce/formfix
Added form validation models and swapped search remote api
- Loading branch information
Showing
3 changed files
with
62 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import LoginForm from './forms/login'; | ||
import CreateAccountForm from './forms/create_account'; | ||
import EditAccountForm from './forms/edit_account'; | ||
import AddressForm from './forms/address'; | ||
|
||
export default { | ||
login: new LoginForm(), | ||
create_account: new CreateAccountForm() | ||
create_account: new CreateAccountForm(), | ||
edit_account: new EditAccountForm(), | ||
address: new AddressForm() | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
export default class { | ||
/** | ||
* @Constructor | ||
*/ | ||
constructor() { | ||
|
||
} | ||
|
||
firstName(value) { | ||
return value.length; | ||
} | ||
|
||
lastName(value) { | ||
return value.length; | ||
} | ||
|
||
email(value) { | ||
let re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; | ||
|
||
return re.test(value); | ||
} | ||
|
||
phone(value) { | ||
value.length; | ||
} | ||
|
||
password(value) { | ||
let r1 = /[A-Za-z]/, // alphabetic | ||
r2 = /[0-9]/; // numeric | ||
|
||
if (!r1.test(value)) { | ||
return false; | ||
} | ||
|
||
if (!r2.test(value)) { | ||
return false; | ||
} | ||
|
||
return value.length >= 7; | ||
} | ||
|
||
passwordMatch(password1, password2) { | ||
return password1 === password2; | ||
} | ||
} |