-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
208 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@keystatic/core': patch | ||
--- | ||
|
||
Fix circular dependencies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export function validateDate( | ||
validation: { min?: string; max?: string; isRequired?: boolean } | undefined, | ||
value: string | null, | ||
label: string | ||
) { | ||
if (value !== null && !/^\d{4}-\d{2}-\d{2}$/.test(value)) { | ||
return `${label} is not a valid date`; | ||
} | ||
|
||
if (validation?.isRequired && value === null) { | ||
return `${label} is required`; | ||
} | ||
if ((validation?.min || validation?.max) && value !== null) { | ||
const date = new Date(value); | ||
if (validation?.min !== undefined) { | ||
const min = new Date(validation.min); | ||
if (date < min) { | ||
return `${label} must be after ${min.toLocaleDateString()}`; | ||
} | ||
} | ||
if (validation?.max !== undefined) { | ||
const max = new Date(validation.max); | ||
if (date > max) { | ||
return `${label} must be no later than ${max.toLocaleDateString()}`; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/keystatic/src/form/fields/datetime/validateDatetime.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export function validateDatetime( | ||
validation: { min?: string; max?: string; isRequired?: boolean } | undefined, | ||
value: string | null, | ||
label: string | ||
) { | ||
if (value !== null && !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(value)) { | ||
return `${label} is not a valid datetime`; | ||
} | ||
|
||
if (validation?.isRequired && value === null) { | ||
return `${label} is required`; | ||
} | ||
if ((validation?.min || validation?.max) && value !== null) { | ||
const datetime = new Date(value); | ||
if (validation?.min !== undefined) { | ||
const min = new Date(validation.min); | ||
if (datetime < min) { | ||
return `${label} must be after ${min.toISOString()}`; | ||
} | ||
} | ||
if (validation?.max !== undefined) { | ||
const max = new Date(validation.max); | ||
if (datetime > max) { | ||
return `${label} must be no later than ${max.toISOString()}`; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/keystatic/src/form/fields/integer/validateInteger.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export function validateInteger( | ||
validation: { min?: number; max?: number; isRequired?: boolean } | undefined, | ||
value: unknown, | ||
label: string | ||
) { | ||
if ( | ||
value !== null && | ||
(typeof value !== 'number' || !Number.isFinite(value)) | ||
) { | ||
return `${label} is not a valid whole number`; | ||
} | ||
|
||
if (validation?.isRequired && value === null) { | ||
return `${label} is required`; | ||
} | ||
if (value !== null) { | ||
if (validation?.min !== undefined && value < validation.min) { | ||
return `${label} must be at least ${validation.min}`; | ||
} | ||
if (validation?.max !== undefined && value > validation.max) { | ||
return `${label} must be at most ${validation.max}`; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
dbd09f0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
keystar-ui – ./design-system/docs
keystar-ui.vercel.app
voussoir.vercel.app
keystar-ui-git-main-thinkmill-labs.vercel.app
keystar-ui-thinkmill-labs.vercel.app
dbd09f0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
keystatic – ./dev-projects/next-app
keystatic.vercel.app
keystatic-thinkmill-labs.vercel.app
keystatic-git-main-thinkmill-labs.vercel.app