mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
fix: only push error when option is required
This commit is contained in:
parent
041db86ac2
commit
d8bf40b60c
@ -644,6 +644,7 @@ export class HandleCommand {
|
||||
if (channel) {
|
||||
if ('channel_types' in i) {
|
||||
if (!(i as SeyfertChannelOption).channel_types!.includes(channel.type)) {
|
||||
if (i.required)
|
||||
errors.push({
|
||||
name: i.name,
|
||||
error: `The entered channel type is not one of ${(i as SeyfertChannelOption)
|
||||
@ -730,6 +731,7 @@ export class HandleCommand {
|
||||
if (option.min_length) {
|
||||
if (value.length < option.min_length) {
|
||||
value = undefined;
|
||||
if (i.required)
|
||||
errors.push({
|
||||
name: i.name,
|
||||
error: `The entered string has less than ${option.min_length} characters. The minimum required is ${option.min_length} characters.`,
|
||||
@ -741,6 +743,7 @@ export class HandleCommand {
|
||||
if (option.max_length) {
|
||||
if (value.length > option.max_length) {
|
||||
value = undefined;
|
||||
if (i.required)
|
||||
errors.push({
|
||||
name: i.name,
|
||||
error: `The entered string has more than ${option.max_length} characters. The maximum required is ${option.max_length} characters.`,
|
||||
@ -753,6 +756,7 @@ export class HandleCommand {
|
||||
const choice = option.choices.find(x => x.name === value);
|
||||
if (!choice) {
|
||||
value = undefined;
|
||||
if (i.required)
|
||||
errors.push({
|
||||
name: i.name,
|
||||
error: `The entered choice is invalid. Please choose one of the following options: ${option.choices
|
||||
@ -778,6 +782,7 @@ export class HandleCommand {
|
||||
}
|
||||
if (Number.isNaN(value)) {
|
||||
value = undefined;
|
||||
if (i.required)
|
||||
errors.push({
|
||||
name: i.name,
|
||||
error: 'The entered choice is an invalid number.',
|
||||
@ -788,6 +793,7 @@ export class HandleCommand {
|
||||
if (option.min_value) {
|
||||
if (value < option.min_value) {
|
||||
value = undefined;
|
||||
if (i.required)
|
||||
errors.push({
|
||||
name: i.name,
|
||||
error: `The entered number is less than ${option.min_value}. The minimum allowed is ${option.min_value}`,
|
||||
@ -799,6 +805,7 @@ export class HandleCommand {
|
||||
if (option.max_value) {
|
||||
if (value > option.max_value) {
|
||||
value = undefined;
|
||||
if (i.required)
|
||||
errors.push({
|
||||
name: i.name,
|
||||
error: `The entered number is greater than ${option.max_value}. The maximum allowed is ${option.max_value}`,
|
||||
@ -812,6 +819,7 @@ export class HandleCommand {
|
||||
const choice = option.choices.find(x => x.name === args[i.name]);
|
||||
if (!choice) {
|
||||
value = undefined;
|
||||
if (i.required)
|
||||
errors.push({
|
||||
name: i.name,
|
||||
error: `The entered choice is invalid. Please choose one of the following options: ${option.choices
|
||||
|
Loading…
x
Reference in New Issue
Block a user