@felte/common
Advanced tools
Comparing version 1.0.0-next.10 to 1.0.0-next.11
@@ -316,5 +316,5 @@ 'use strict'; | ||
return; | ||
if (objValue === null) | ||
if (objValue === null || objValue === '') | ||
return srcValue; | ||
if (srcValue === null) | ||
if (srcValue === null || srcValue === '') | ||
return objValue; | ||
@@ -329,9 +329,16 @@ if (!objValue || !srcValue) | ||
} | ||
function mergeErrors(errors) { | ||
return _mergeWith(...errors, executeCustomizer); | ||
} | ||
function runValidations(values, validationOrValidations) { | ||
if (!validationOrValidations) | ||
return []; | ||
const validations = Array.isArray(validationOrValidations) | ||
? validationOrValidations | ||
: [validationOrValidations]; | ||
return validations.map((v) => v(values)); | ||
} | ||
async function executeValidation(values, validations) { | ||
if (!validations) | ||
return; | ||
if (!Array.isArray(validations)) | ||
return validations(values); | ||
const errorArray = await Promise.all(validations.map((v) => v(values))); | ||
return _mergeWith(...errorArray, executeCustomizer); | ||
const errors = await Promise.all(runValidations(values, validations)); | ||
return mergeErrors(errors); | ||
} | ||
@@ -538,2 +545,4 @@ | ||
exports.isTextAreaElement = isTextAreaElement; | ||
exports.mergeErrors = mergeErrors; | ||
exports.runValidations = runValidations; | ||
exports.setControlValue = setControlValue; | ||
@@ -540,0 +549,0 @@ exports.setForm = setForm; |
@@ -21,5 +21,5 @@ export { _some } from './utils/some.js'; | ||
export { getValue } from './utils/getValue.js'; | ||
export { executeValidation } from './utils/executeValidation.js'; | ||
export { executeValidation, mergeErrors, runValidations } from './utils/executeValidation.js'; | ||
export { executeTransforms } from './utils/executeTransforms.js'; | ||
export { addAttrsFromFieldset, getFormControls, getFormDefaultValues, getInputTextOrNumber, setControlValue, setForm } from './utils/domUtils.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -7,5 +7,5 @@ import { _mergeWith } from './mergeWith.js'; | ||
return; | ||
if (objValue === null) | ||
if (objValue === null || objValue === '') | ||
return srcValue; | ||
if (srcValue === null) | ||
if (srcValue === null || srcValue === '') | ||
return objValue; | ||
@@ -20,12 +20,19 @@ if (!objValue || !srcValue) | ||
} | ||
function mergeErrors(errors) { | ||
return _mergeWith(...errors, executeCustomizer); | ||
} | ||
function runValidations(values, validationOrValidations) { | ||
if (!validationOrValidations) | ||
return []; | ||
const validations = Array.isArray(validationOrValidations) | ||
? validationOrValidations | ||
: [validationOrValidations]; | ||
return validations.map((v) => v(values)); | ||
} | ||
async function executeValidation(values, validations) { | ||
if (!validations) | ||
return; | ||
if (!Array.isArray(validations)) | ||
return validations(values); | ||
const errorArray = await Promise.all(validations.map((v) => v(values))); | ||
return _mergeWith(...errorArray, executeCustomizer); | ||
const errors = await Promise.all(runValidations(values, validations)); | ||
return mergeErrors(errors); | ||
} | ||
export { executeValidation }; | ||
export { executeValidation, mergeErrors, runValidations }; | ||
//# sourceMappingURL=executeValidation.js.map |
@@ -21,6 +21,6 @@ export { _some } from "./utils/some"; | ||
export { getValue } from "./utils/getValue"; | ||
export { executeValidation } from "./utils/executeValidation"; | ||
export { executeValidation, mergeErrors, runValidations } from "./utils/executeValidation"; | ||
export { executeTransforms } from "./utils/executeTransforms"; | ||
export * from "./utils/domUtils"; | ||
export * from "./types-1f3e4b02"; | ||
export * from "./types-bd0578fb"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,4 +0,4 @@ | ||
import { Obj } from "../types-1f3e4b02"; | ||
import { Obj } from "../types-bd0578fb"; | ||
/** @ignore */ | ||
declare function _cloneDeep<T extends Obj>(obj: T): T; | ||
export { _cloneDeep }; |
@@ -1,2 +0,2 @@ | ||
import { Obj, DeepSetResult } from "../types-1f3e4b02"; | ||
import { Obj, DeepSetResult } from "../types-bd0578fb"; | ||
/** | ||
@@ -3,0 +3,0 @@ * @category Helper |
@@ -1,2 +0,2 @@ | ||
import { Obj } from "../types-1f3e4b02"; | ||
import { Obj } from "../types-bd0578fb"; | ||
/** | ||
@@ -3,0 +3,0 @@ * @category Helper |
@@ -1,4 +0,4 @@ | ||
import { Obj } from "../types-1f3e4b02"; | ||
import { Obj } from "../types-bd0578fb"; | ||
/** @ignore */ | ||
declare function _defaultsDeep<T extends Obj>(...args: any[]): T; | ||
export { _defaultsDeep }; |
@@ -1,2 +0,2 @@ | ||
import { FormControl, Obj, FieldValue } from "../types-1f3e4b02"; | ||
import { FormControl, Obj, FieldValue } from "../types-bd0578fb"; | ||
/** | ||
@@ -3,0 +3,0 @@ * @ignore |
@@ -1,3 +0,3 @@ | ||
import { Obj, TransformFunction } from "../types-1f3e4b02"; | ||
import { Obj, TransformFunction } from "../types-bd0578fb"; | ||
declare function executeTransforms<Data extends Obj>(values: Obj, transforms?: TransformFunction<Data>[] | TransformFunction<Data>): ReturnType<TransformFunction<Data>>; | ||
export { executeTransforms }; |
@@ -1,3 +0,5 @@ | ||
import { Obj, ValidationFunction } from "../types-1f3e4b02"; | ||
declare function executeValidation<Data extends Obj>(values: Data, validations?: ValidationFunction<Data>[] | ValidationFunction<Data>): Promise<ReturnType<ValidationFunction<Data>>>; | ||
export { executeValidation }; | ||
import { Obj, ValidationFunction, Errors, RecursivePartial } from "../types-bd0578fb"; | ||
declare function mergeErrors<Data extends Obj>(errors: (RecursivePartial<Data> | undefined)[]): Data; | ||
declare function runValidations<Data extends Obj>(values: Data, validationOrValidations?: ValidationFunction<Data>[] | ValidationFunction<Data>): ReturnType<ValidationFunction<Data>>[]; | ||
declare function executeValidation<Data extends Obj>(values: Data, validations?: ValidationFunction<Data>[] | ValidationFunction<Data>): Promise<Errors<Data>>; | ||
export { mergeErrors, runValidations, executeValidation }; |
@@ -1,4 +0,4 @@ | ||
import { Obj, FieldValue } from "../types-1f3e4b02"; | ||
import { Obj, FieldValue } from "../types-bd0578fb"; | ||
/** @ignore */ | ||
declare function _get<Data extends Obj, Default = undefined>(obj: Data, path: string, defaultValue?: Default): Default | FieldValue | FieldValue[]; | ||
export { _get }; |
@@ -1,2 +0,2 @@ | ||
import { FormControl } from "../types-1f3e4b02"; | ||
import { FormControl } from "../types-bd0578fb"; | ||
/** | ||
@@ -3,0 +3,0 @@ * @category Helper |
@@ -1,3 +0,3 @@ | ||
import { FormControl } from "../types-1f3e4b02"; | ||
import { FormControl } from "../types-bd0578fb"; | ||
declare function getPathFromDataset(el: FormControl): string; | ||
export { getPathFromDataset }; |
@@ -1,2 +0,6 @@ | ||
declare function getValue<T, R>(storeValue: T, selectorOrPath?: ((value: T) => R) | string): string | number | boolean | File | import("../types-1f3e4b02").FieldValue[] | T | R | null | undefined; | ||
import { Paths, Traverse, Obj } from "../types-bd0578fb"; | ||
declare function getValue<T>(storeValue: T): T; | ||
declare function getValue<T extends Obj, R>(storeValue: T, selector: (value: T) => R): R; | ||
declare function getValue<T extends Obj, P extends Paths<T> = Paths<T>>(storeValue: T, path: P): Traverse<T, P>; | ||
declare function getValue<T>(storeValue: T, selectorOrPath: string | ((value: any) => any)): T; | ||
export { getValue }; |
@@ -1,4 +0,4 @@ | ||
import { FieldValue } from "../types-1f3e4b02"; | ||
import { FieldValue } from "../types-bd0578fb"; | ||
/** @category Helper */ | ||
declare function isFieldValue(value: unknown): value is FieldValue; | ||
export { isFieldValue }; |
@@ -1,4 +0,4 @@ | ||
import { Obj } from "../types-1f3e4b02"; | ||
import { Obj } from "../types-bd0578fb"; | ||
/** @ignore */ | ||
declare function _mapValues(obj: Obj, updater: (value: unknown) => unknown): Obj; | ||
export { _mapValues }; |
@@ -1,4 +0,4 @@ | ||
import { Obj } from "../types-1f3e4b02"; | ||
import { Obj } from "../types-bd0578fb"; | ||
/** @ignore */ | ||
declare function _merge<T extends Obj>(...args: any[]): T; | ||
export { _merge }; |
@@ -1,4 +0,4 @@ | ||
import { Obj } from "../types-1f3e4b02"; | ||
import { Obj } from "../types-bd0578fb"; | ||
/** @ignore */ | ||
declare function _mergeWith<T extends Obj>(...args: any[]): T; | ||
export { _mergeWith }; |
@@ -1,4 +0,4 @@ | ||
import { Obj, FieldValue } from "../types-1f3e4b02"; | ||
import { Obj, FieldValue } from "../types-bd0578fb"; | ||
/** @ignore */ | ||
declare function _set<Data extends Obj>(obj: Data | undefined, path: string | string[], value: FieldValue | FieldValue[]): Data; | ||
export { _set }; |
@@ -1,4 +0,4 @@ | ||
import { Obj } from "../types-1f3e4b02"; | ||
import { Obj } from "../types-bd0578fb"; | ||
/** @ignore */ | ||
declare function _some(obj: Obj, pred: (value: unknown) => boolean): boolean; | ||
export { _some }; |
@@ -1,2 +0,2 @@ | ||
import { FormControl } from "../types-1f3e4b02"; | ||
import { FormControl } from "../types-bd0578fb"; | ||
/** | ||
@@ -3,0 +3,0 @@ * @category Helper |
@@ -1,2 +0,2 @@ | ||
import { Obj } from "../types-1f3e4b02"; | ||
import { Obj } from "../types-bd0578fb"; | ||
/** @ignore */ | ||
@@ -3,0 +3,0 @@ declare function _unset(obj: undefined, path: string | string[]): undefined; |
@@ -1,4 +0,4 @@ | ||
import { Obj, FieldValue } from "../types-1f3e4b02"; | ||
import { Obj, FieldValue } from "../types-bd0578fb"; | ||
/** @ignore */ | ||
declare function _update<Data extends Obj, Value = FieldValue>(obj: Data | undefined, path: string, updater: (value: Value) => Value): Data; | ||
export { _update }; |
{ | ||
"name": "@felte/common", | ||
"version": "1.0.0-next.10", | ||
"version": "1.0.0-next.11", | ||
"description": "Common utilities for Felte packages", | ||
@@ -5,0 +5,0 @@ "author": "Pablo Berganza <pablo@berganza.dev>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
142567
1558