createAttributeUpdater
createAttributeUpdater<
T>(attributes,setAttributes,validate,onValidationError?): <K>(key,value) =>boolean
Defined in: wp-typia-block-runtime/src/validation.ts:298
Create a shallow attribute updater that validates before committing changes.
Type Parameters
Section titled “Type Parameters”T extends object
Parameters
Section titled “Parameters”attributes
Section titled “attributes”T
Current attribute snapshot.
setAttributes
Section titled “setAttributes”(attrs) => void
Setter used to apply validated patches.
validate
Section titled “validate”(value) => ValidationResult<T>
Validator used to check the next attribute state.
onValidationError?
Section titled “onValidationError?”(result, key) => void
Optional callback for rejected updates.
Returns
Section titled “Returns”A keyed updater that returns true when the patch is accepted.
<K>(key, value) => boolean
Example
Section titled “Example”const update = createAttributeUpdater(attributes, setAttributes, validate);