Commit 0824d3dd authored by Maxym Borodenko's avatar Maxym Borodenko
Browse files

#337 Partner email validator

parent 7a9c94d1
Pipeline #5639 passed with stages
in 3 minutes and 38 seconds
......@@ -57,12 +57,12 @@ class PartnerForm extends React.Component<any, void> {
<Field name="email" component={ TextField } type="text" label="Email address"
placeholder="name@domain.com"
validate={ [ Validators.maxLength(100), Validators.emailAddress ] }
validate={ [ Validators.maxLength100, Validators.emailAddress ] }
/>
<Field name="phone" component={ TextField } type="text" label="Phone number"
placeholder="+1 555 1231 Ext. 13"
validate={ [ Validators.maxLength(100), Validators.phoneNumber ] }
validate={ [ Validators.phoneNumber ] }
/>
<Field name="address" component={ TextField } type="text" label="Address"
......
......@@ -6,6 +6,7 @@ export default class Validators {
public static maxLength = (max) => (value) => value && value.length > max ? `Must be ${max} characters or less` : undefined;
public static maxLength20 = Validators.maxLength(20);
public static maxLength100 = Validators.maxLength(100);
public static emailAddress = (value) => !value || value.match(/^[\w\d\-\+\._]+@[\w\d\-_]+(\.[\w\d\-_]+)*$/g) ? undefined : 'Invalid email address';
public static phoneNumber = (value) => !value || value.match(/^\+[\d\-\. ]+( ext\. \d+)?$/gi) ? undefined : 'Invalid number format: only digits and + . - allowed';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment