muba-input-text 3.0.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/InputText.js CHANGED
@@ -32,6 +32,7 @@ export default class InputText extends React.Component {
32
32
  fieldError: false,
33
33
  requiredError: false,
34
34
  onlyNumbersError: false,
35
+ minValueError: false,
35
36
  maxValueError: false,
36
37
  emailBadFormat: false,
37
38
  customizedError: false,
@@ -61,6 +62,7 @@ export default class InputText extends React.Component {
61
62
  fieldError: false,
62
63
  requiredError: false,
63
64
  onlyNumbersError: false,
65
+ minValueError: false,
64
66
  maxValueError: false,
65
67
  emailBadFormat: false
66
68
  });
@@ -112,7 +114,8 @@ export default class InputText extends React.Component {
112
114
  return false;
113
115
  } else {
114
116
  const pattern = new RegExp("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])", 'i');
115
- const success = !!pattern.test(this.props.value);
117
+ const patternSpaces = new RegExp(/\s/);
118
+ const success = !!pattern.test(this.props.value) && !patternSpaces.test(this.props.value);
116
119
 
117
120
  if (!success) {
118
121
  // It's invalid
@@ -132,10 +135,14 @@ export default class InputText extends React.Component {
132
135
  this.showError();
133
136
  this.setState({ onlyNumbersError: true });
134
137
  return false;
135
- } else if (this.props.maxValue && this.props.value > this.props.maxValue) {
138
+ } else if (this.props.maxValue && parseInt(this.props.value) > this.props.maxValue) {
136
139
  this.showError();
137
140
  this.setState({ maxValueError: true });
138
141
  return false;
142
+ } else if (this.props.minValue && parseInt(this.props.value) < this.props.minValue) {
143
+ this.showError();
144
+ this.setState({ minValueError: true });
145
+ return false;
139
146
  }
140
147
  return true;
141
148
  }
@@ -152,6 +159,7 @@ export default class InputText extends React.Component {
152
159
  fieldError: false,
153
160
  requiredError: false,
154
161
  onlyNumbersError: false,
162
+ minValueError: false,
155
163
  maxValueError: false,
156
164
  emailBadFormat: false,
157
165
  customizedError: false,
@@ -198,6 +206,7 @@ export default class InputText extends React.Component {
198
206
  {this.state.requiredError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('requiredField')}</OutputText> : null}
199
207
  {this.state.onlyNumbersError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('onlyNumbers')}</OutputText> : null}
200
208
  {this.state.maxValueError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('maxValueError', { maxValue: this.props.maxValue })}</OutputText> : null}
209
+ {this.state.minValueError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('minValueError', { minValue: this.props.minValue })}</OutputText> : null}
201
210
  {this.state.emailBadFormat && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('emailBadFormat')}</OutputText> : null}
202
211
  {this.state.maxCharacters && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {strings('maxCharacters', { maxCharacters: this.props.maxCharacters })}</OutputText> : null}
203
212
  {this.state.customizedError && (this.props.showErrorText == null || this.props.showErrorText) ? <OutputText style={[inputTextStyles.subNote, inputTextStyles.redText]}> {this.state.customizedErrorMessage}</OutputText> : null}
package/locales/ar.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "requiredField": "الحقول المطلوبة",
3
3
  "onlyNumbers": "استخدم الأرقام فقط",
4
+ "minValueError": "الحد الأدنى للقيمة المسموح بها هو {{minValue}}",
4
5
  "maxValueError": "الحد الأقصى للقيمة المسموح بها هو {{maxValue}}",
5
6
  "emailBadFormat": "رجاء قم بإدخال بريد إكتروني صحيح",
6
7
  "maxCharacters": "الحد الأقصى للحروف {{maxCharacters}}"
package/locales/en.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "requiredField": "Required field",
3
3
  "onlyNumbers": "Use numbers only",
4
+ "minValueError": "The minimum value allowed is {{minValue}}",
4
5
  "maxValueError": "The maximum value allowed is {{maxValue}}",
5
6
  "emailBadFormat": "Please enter a valid email address",
6
7
  "maxCharacters": "{{maxCharacters}} characters max."
package/locales/es.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "requiredField": "Campo obligatorio",
3
3
  "onlyNumbers": "Utiliza sólo números",
4
+ "minValueError": "El valor mínimo permitido es {{minValue}}",
4
5
  "maxValueError": "El valor máximo permitido es {{maxValue}}",
5
6
  "emailBadFormat": "Por favor, introduce una dirección de correo electrónico válida",
6
7
  "maxCharacters": "{{maxCharacters}} caracteres máx."
package/locales/fr.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "requiredField": "Champs requis",
3
3
  "onlyNumbers": "Utiliser des chiffres seulement",
4
+ "minValueError": "La valeur minimale autorisée est {{minValue}}",
4
5
  "maxValueError": "La valeur maximale autorisée est {{maxValue}}",
5
6
  "emailBadFormat": "S'il vous plaît, mettez une adresse email valide",
6
7
  "maxCharacters": "{{maxCharacters}} caractères max."
package/locales/it.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "requiredField": "Campo obbligatorio",
3
3
  "onlyNumbers": "Usa solo numeri",
4
+ "minValueError": "Il valore minimo permesso è {{minValue}}",
4
5
  "maxValueError": "Il valore massimo permesso è {{maxValue}}",
5
6
  "emailBadFormat": "Inserisci un indirizzo e-mail valido",
6
7
  "maxCharacters": "{{maxCharacters}} caratteri massimi"
package/locales/nl.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "requiredField": "Verplicht veld",
3
3
  "onlyNumbers": "Gebruik alleen cijfers",
4
+ "minValueError": "De minimale toegestane waarde is {minValue}}",
4
5
  "maxValueError": "De maximale toegestane waarde is {maxValue}}",
5
6
  "emailBadFormat": "Voer een geldig e-mailadres in",
6
7
  "maxCharacters": "Maximaal {{maxCharacters} tekens"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muba-input-text",
3
- "version": "3.0.1",
3
+ "version": "4.0.0",
4
4
  "description": "Input text",
5
5
  "main": "InputText.js",
6
6
  "scripts": {
@@ -17,8 +17,8 @@
17
17
  },
18
18
  "homepage": "https://github.com/Mubawab/muba-input-text#readme",
19
19
  "dependencies": {
20
- "muba-font": "3",
21
- "muba-i18n": "3",
22
- "muba-output-text": "3"
20
+ "muba-font": "4",
21
+ "muba-i18n": "4",
22
+ "muba-output-text": "4"
23
23
  }
24
- }
24
+ }