@colisweb/rescript-toolkit 5.36.0 → 5.37.1
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/package.json
CHANGED
package/src/form/ReSchema.res
CHANGED
|
@@ -77,6 +77,12 @@ module Make = (Lenses: Lenses) => {
|
|
|
77
77
|
error: option<string>,
|
|
78
78
|
}): t
|
|
79
79
|
| ArrayNonEmpty({field: Lenses.field<array<'a>>, error: option<string>}): t
|
|
80
|
+
| ForbiddenCharaters({
|
|
81
|
+
field: Lenses.field<string>,
|
|
82
|
+
characters: array<string>,
|
|
83
|
+
optionalPredicate?: Lenses.state => bool,
|
|
84
|
+
error: option<string>,
|
|
85
|
+
}): t
|
|
80
86
|
|
|
81
87
|
type schema = array<t>
|
|
82
88
|
|
|
@@ -124,6 +130,9 @@ module Make = (Lenses: Lenses) => {
|
|
|
124
130
|
let nonEmpty = (~error=?, ~optionalPredicate=?, field) => [
|
|
125
131
|
StringNonEmpty({field, ?optionalPredicate, error}),
|
|
126
132
|
]
|
|
133
|
+
let forbiddenCharacters = (~error=?, ~optionalPredicate=?, ~characters, field) => [
|
|
134
|
+
ForbiddenCharaters({field, ?optionalPredicate, characters, error}),
|
|
135
|
+
]
|
|
127
136
|
|
|
128
137
|
let string = (~min=?, ~minError=?, ~max=?, ~maxError=?, field) => {
|
|
129
138
|
mergeValidators([
|
|
@@ -389,6 +398,19 @@ module Make = (Lenses: Lenses) => {
|
|
|
389
398
|
: Valid,
|
|
390
399
|
)
|
|
391
400
|
}
|
|
401
|
+
| Validation.ForbiddenCharaters({field, error, characters} as props) => {
|
|
402
|
+
let value = Lenses.get(values, field)
|
|
403
|
+
let isOptional = props.optionalPredicate->Option.mapWithDefault(false, fn => fn(values))
|
|
404
|
+
|
|
405
|
+
(
|
|
406
|
+
Field(field),
|
|
407
|
+
isOptional
|
|
408
|
+
? Valid
|
|
409
|
+
: characters->Array.some(char => value->Js.String2.includes(char))
|
|
410
|
+
? Error(error->Option.getWithDefault(i18n.invalidCharacter(characters)))
|
|
411
|
+
: Valid,
|
|
412
|
+
)
|
|
413
|
+
}
|
|
392
414
|
}
|
|
393
415
|
|
|
394
416
|
let getFieldValidator = (~validators, ~fieldName) =>
|
|
@@ -414,6 +436,7 @@ module Make = (Lenses: Lenses) => {
|
|
|
414
436
|
| Validation.ArrayNonEmpty({field}) => Field(field) == fieldName
|
|
415
437
|
| Validation.CustomNestedSchema2({field}) => Field(field) == fieldName
|
|
416
438
|
| Validation.Phone({field}) => Field(field) == fieldName
|
|
439
|
+
| Validation.ForbiddenCharaters({field}) => Field(field) == fieldName
|
|
417
440
|
}
|
|
418
441
|
)
|
|
419
442
|
|
|
@@ -440,6 +463,7 @@ module Make = (Lenses: Lenses) => {
|
|
|
440
463
|
| Validation.CustomNestedSchema2({field}) => Field(field) == fieldName
|
|
441
464
|
| Validation.OptionNonEmpty({field}) => Field(field) == fieldName
|
|
442
465
|
| Validation.ArrayNonEmpty({field}) => Field(field) == fieldName
|
|
466
|
+
| Validation.ForbiddenCharaters({field}) => Field(field) == fieldName
|
|
443
467
|
}
|
|
444
468
|
)
|
|
445
469
|
|
|
@@ -13,6 +13,7 @@ type t = {
|
|
|
13
13
|
phone: string,
|
|
14
14
|
passwordTooShort: string,
|
|
15
15
|
passwordCantContainLogin: string,
|
|
16
|
+
invalidCharacter: array<string> => string,
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
let default = {
|
|
@@ -37,4 +38,8 @@ let default = {
|
|
|
37
38
|
phone: "Format du numéro invalide. Ex : +33612345678",
|
|
38
39
|
passwordTooShort: "Le mot de passe doit contenir au moins 10 caractères, avoir au moins 1 minuscule, 1 majuscule et un chiffre.",
|
|
39
40
|
passwordCantContainLogin: "Le mot de passe ne peut pas contenir l'identifiant.",
|
|
41
|
+
invalidCharacter: characters =>
|
|
42
|
+
`Ce champ contient un caractère non autorisé parmi cette liste: ${characters->Js.Array2.joinWith(
|
|
43
|
+
" ",
|
|
44
|
+
)}`,
|
|
40
45
|
}
|
package/src/form/Reform.res
CHANGED
|
@@ -124,6 +124,7 @@ module Make = (Config: Config) => {
|
|
|
124
124
|
| Validation.CustomNestedSchema2({field}) => (Field(field), Pristine)
|
|
125
125
|
| Validation.OptionNonEmpty({field}) => (Field(field), Pristine)
|
|
126
126
|
| Validation.ArrayNonEmpty({field}) => (Field(field), Pristine)
|
|
127
|
+
| Validation.ForbiddenCharaters({field}) => (Field(field), Pristine)
|
|
127
128
|
}
|
|
128
129
|
)
|
|
129
130
|
}
|
|
@@ -87,7 +87,11 @@ and instanceCell = {
|
|
|
87
87
|
render: (string, unit) => React.element,
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
type rec filterProps<'filterValue> = {
|
|
90
|
+
type rec filterProps<'filterValue, 'filter> = {
|
|
91
|
+
column: filterColumn<'filterValue>,
|
|
92
|
+
state: state,
|
|
93
|
+
setFilter: (string, 'filter) => unit,
|
|
94
|
+
}
|
|
91
95
|
and filterColumn<'filterValue> = {
|
|
92
96
|
filterValue: option<'filterValue>,
|
|
93
97
|
setFilter: option<'filterValue> => unit,
|
|
@@ -99,7 +103,7 @@ external makeColumn: (
|
|
|
99
103
|
~accessor: 'data => 'cellValue,
|
|
100
104
|
~id: string,
|
|
101
105
|
~header: React.element,
|
|
102
|
-
~filterRender: filterProps<'filterValue> => React.element=?,
|
|
106
|
+
~filterRender: filterProps<'filterValue, 'filter> => React.element=?,
|
|
103
107
|
~filter: string=?,
|
|
104
108
|
~cell: cellProps<'cellValue> => React.element=?,
|
|
105
109
|
~minWidth: int=?,
|