mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 19:43:29 +01:00
chore: bump shapeshift for faster object validation (#7914)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { s } from '@sapphire/shapeshift';
|
||||
import type { APIEmbedField } from 'discord-api-types/v10';
|
||||
|
||||
export const fieldNamePredicate = s.string.lengthGe(1).lengthLe(256);
|
||||
export const fieldNamePredicate = s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(256);
|
||||
|
||||
export const fieldValuePredicate = s.string.lengthGe(1).lengthLe(1024);
|
||||
export const fieldValuePredicate = s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(1024);
|
||||
|
||||
export const fieldInlinePredicate = s.boolean.optional;
|
||||
|
||||
@@ -15,7 +15,7 @@ export const embedFieldPredicate = s.object({
|
||||
|
||||
export const embedFieldsArrayPredicate = embedFieldPredicate.array;
|
||||
|
||||
export const fieldLengthPredicate = s.number.le(25);
|
||||
export const fieldLengthPredicate = s.number.lessThanOrEqual(25);
|
||||
|
||||
export function validateFieldLength(amountAdding: number, fields?: APIEmbedField[]): void {
|
||||
fieldLengthPredicate.parse((fields?.length ?? 0) + amountAdding);
|
||||
@@ -37,15 +37,15 @@ export const embedAuthorPredicate = s.object({
|
||||
url: urlPredicate,
|
||||
});
|
||||
|
||||
export const RGBPredicate = s.number.int.ge(0).le(255);
|
||||
export const RGBPredicate = s.number.int.greaterThanOrEqual(0).lessThanOrEqual(255);
|
||||
export const colorPredicate = s.number.int
|
||||
.ge(0)
|
||||
.le(0xffffff)
|
||||
.greaterThanOrEqual(0)
|
||||
.lessThanOrEqual(0xffffff)
|
||||
.or(s.tuple([RGBPredicate, RGBPredicate, RGBPredicate])).nullable;
|
||||
|
||||
export const descriptionPredicate = s.string.lengthGe(1).lengthLe(4096).nullable;
|
||||
export const descriptionPredicate = s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(4096).nullable;
|
||||
|
||||
export const footerTextPredicate = s.string.lengthGe(1).lengthLe(2048).nullable;
|
||||
export const footerTextPredicate = s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(2048).nullable;
|
||||
|
||||
export const embedFooterPredicate = s.object({
|
||||
text: footerTextPredicate,
|
||||
|
||||
Reference in New Issue
Block a user