chore: bump shapeshift for faster object validation (#7914)

This commit is contained in:
Parbez
2022-05-12 15:39:50 +05:30
committed by GitHub
parent c1b5e731da
commit 4515a1ea80
10 changed files with 40 additions and 40 deletions

View File

@@ -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,