From ea4d83e8df16f31df162fbcb3cfbcdeb471f98fd Mon Sep 17 00:00:00 2001 From: Adrien Morel <148890919+ad-momo@users.noreply.github.com> Date: Mon, 13 Apr 2026 10:40:04 +0200 Subject: [PATCH] Enhance isMoney rule to ignore optional field Added a check for field definition in isMoney rule. --- content/docs/extend/custom_schema_types.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/content/docs/extend/custom_schema_types.md b/content/docs/extend/custom_schema_types.md index 2ccb2e3..0edd714 100644 --- a/content/docs/extend/custom_schema_types.md +++ b/content/docs/extend/custom_schema_types.md @@ -28,6 +28,14 @@ import { USD } from '@dinero.js/currencies' import { FieldContext } from '@vinejs/vine/types' const isMoneyRule = vine.createRule(function isMoney(value: unknown, _, field: FieldContext) => { + + /** + * Ignore optional + */ + if(!field.isDefined){ + return false + } + /** * Convert string representation of a number to a JavaScript * Number data type.