OSDN Git Service

regex improvement
authorZhiting Lin <zlin035@uottawa.ca>
Tue, 3 Apr 2018 09:58:49 +0000 (17:58 +0800)
committerZhiting Lin <zlin035@uottawa.ca>
Tue, 3 Apr 2018 09:58:49 +0000 (17:58 +0800)
src/features/accounts/components/New.jsx
src/features/assets/components/New.jsx
src/features/transactions/components/New/New.jsx
src/features/transactions/components/New/New.scss

index 7c33fcd..a69783b 100644 (file)
@@ -58,7 +58,7 @@ const validate = values => {
   const tagError = JsonField.validator(values.tags)
   if (tagError) { errors.tags = tagError }
 
-  if (!values.alias) { errors.alias = 'Require' }
+  if (!values.alias) { errors.alias = 'Account alias is required' }
 
   return errors
 }
index 35420ea..24624b9 100644 (file)
@@ -60,7 +60,7 @@ const validate = values => {
     if (fieldError) { errors[key] = fieldError }
   })
 
-  if (!values.alias) { errors.alias = 'Require' }
+  if (!values.alias) { errors.alias = 'Asset alias is required' }
 
   return errors
 }
index 0ed45d9..23f7f1f 100644 (file)
@@ -360,7 +360,7 @@ const validate = values => {
   // Actions
   let numError
   values.actions.forEach((action, index) => {
-    numError = (!/^[0-9.]*$/i.test(values.actions[index].amount))
+    numError = (!/^\d+(\.\d+)?$/i.test(values.actions[index].amount))
     if ( numError) {
       errors.actions[index] = {...errors.actions[index], amount: 'Invalid amount type'}
     }
@@ -368,10 +368,10 @@ const validate = values => {
 
   // Numerical
   let normalTx = values.normalTransaction || ''
-  if (!/^[0-9.]*$/i.test(normalTx.amount)) {
+  if (!/^\d+(\.\d+)?$/i.test(normalTx.amount)) {
     errors.normalTransaction.amount = 'Invalid amount type'
   }
-  if (!/^[0-9.]*$/i.test(normalTx.gas.price)) {
+  if (!/^\d+(\.\d+)?$/i.test(normalTx.gas.price)) {
     errors.normalTransaction.gas.price = 'Invalid amount type'
   }
 
index 93e25b2..95287c3 100644 (file)
@@ -50,7 +50,7 @@
   top: -30px;
 }
 
-.optionsBtnContianer{
+.optionsBtnContianer {
   display: flex;
   flex-direction: column;
   border-radius: 3px;
   }
 }
 
-.optionsBtn{
+.optionsBtn {
   margin: 5px 0;
 }
 
-.optionsLabel{
+.optionsLabel {
   vertical-align: top;
   width: 150px;
-}
\ No newline at end of file
+}