refactor dialog to prevent multiple parent renders

This commit is contained in:
Proddy
2023-04-18 22:04:00 +02:00
parent 8eb7793cd0
commit 6bd744f12e
23 changed files with 622 additions and 501 deletions

View File

@@ -1,12 +1,13 @@
import Schema, { InternalRuleItem, ValidateOption } from 'async-validator';
import type { InternalRuleItem, ValidateOption } from 'async-validator';
import type Schema from 'async-validator';
export const validate = <T extends object>(
validator: Schema,
source: Partial<T>,
options?: ValidateOption
): Promise<T> => {
return new Promise((resolve, reject) => {
validator.validate(source, options ? options : {}, (errors, fieldErrors) => {
): Promise<T> =>
new Promise((resolve, reject) => {
void validator.validate(source, options ? options : {}, (errors, fieldErrors) => {
if (errors) {
reject(fieldErrors);
} else {
@@ -14,7 +15,6 @@ export const validate = <T extends object>(
}
});
});
};
// updated to support both IPv4 and IPv6
const IP_ADDRESS_REGEXP =