Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions frontend/.changeset/busy-terms-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'pydantic-forms': minor
---

Removes some unused functionality. Introduces shouldRegister=true to react-hook-form creation.
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,16 @@ export const zodValidationPresets: PydanticFormZodValidationPresets = {

let validationRule = z.string().trim();
if (minLength) {
validationRule = validationRule?.min(
minLength,
minLength === 1
? 'Moet ingevuld zijn'
: `Dit veld heeft een minimum lengte van ${minLength} karakters`,
);
validationRule = validationRule?.min(minLength);
}

if (maxLength) {
validationRule = validationRule?.max(
maxLength,
`Dit veld heeft een maximum lengte van ${maxLength} karakters`,
);
validationRule = validationRule?.max(maxLength);
}

if (pattern) {
try {
validationRule = validationRule?.regex(
new RegExp(pattern),
`De invoer is niet volgens het juiste formaat: ${pattern}`,
);
validationRule = validationRule?.regex(new RegExp(pattern));
} catch (error) {
console.error(
'Could not parse validation rule regex',
Expand Down
Loading