feat: add disableArrayWarning option to SlugOptions #7174
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Adds
disableArrayWarning
to theSlugOptions
interface. Purpose is to allow users to disable the automatic array warning for slug fields within arrays.Below is warning seen in the console.
Following the steps suggested by the warning works and stops the warning from showing up. However, if the developer creating the schema is using TypeScript they are hit with the following error
So adding
disableArrayWarning
removes that TS error.Also a change to the
schemaOptions
const
within theslugValidator.ts
file as its type assertion is not needed due todisableArrayWarning
is now included within theSlugOptions
interface.What to review
Review the changes to the
SlugOptions
interface found in theslug.ts
file and to thedefaultIsUnique
function, specifically theschemaOptions
variable. Ensure that when enabling
disableArrayWarning` no TS error appears.Testing
I did not add testing, I honestly do not know how but checking out the other slug functions and options I believe there is none. I have tested it with my own repos where I have used a slug field within an array.
Notes for release
This PR adds the
disableArrayWarning
option to theSlugOptions
interface removing the TS error that appears whendisableArrayWarning
does not exist within the interface.