How to use the objection.ValidationError function in objection

To help you get started, we’ve selected a few objection examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github strues / boldr / project / server / models / BaseModel.js View on Github external
.then(row => {
                    if (row) {
                      // eslint-disable-next-line prefer-const
                      let errors = {};

                      property.forEach(prop => {
                        errors[prop] = [
                          {
                            message: `${prop} is already taken.`,
                          },
                        ];
                      });

                      return reject(new ValidationError(errors));
                    }

                    return resolve();
                  })
                  .catch(reject);
github strues / boldr / packages / server / src / models / BaseModel.js View on Github external
.then(row => {
                    if (row) {
                      // eslint-disable-next-line prefer-const
                      let errors = {};

                      property.forEach(prop => {
                        errors[prop] = [
                          {
                            message: `${prop} is already taken.`,
                          },
                        ];
                      });

                      return reject(new ValidationError(errors));
                    }

                    return resolve();
                  })
                  .catch(reject);
github strues / boldr / packages / server / src / models / BaseModel.js View on Github external
.then(row => {
                  if (row) {
                    return reject(
                      new ValidationError({
                        [property]: [
                          {
                            message: `${property} is already taken.`,
                          },
                        ],
                      }),
                    );
                  }

                  return resolve();
                })
                .catch(reject);
github argos-ci / argos / src / server / models / ScreenshotDiff.js View on Github external
$afterValidate(json) {
    if (
      json.baseScreenshotId &&
      json.baseScreenshotId === json.compareScreenshotId
    ) {
      throw new ValidationError({
        type: ValidationError.Type.ModelValidation,
        message: 'The base screenshot should be different to the compare one.',
      })
    }
  }
}
github argos-ci / argos / src / server / models / Build.js View on Github external
$afterValidate(json) {
    if (
      json.baseScreenshotBucketId &&
      json.baseScreenshotBucketId === json.compareScreenshotBucketId
    ) {
      throw new ValidationError({
        type: ValidationError.Type.ModelValidation,
        message:
          'The base screenshot bucket should be different to the compare one.',
      })
    }
  }
github strues / boldr / project / server / models / BaseModel.js View on Github external
.then(row => {
                  if (row) {
                    return reject(
                      new ValidationError({
                        [property]: [
                          {
                            message: `${property} is already taken.`,
                          },
                        ],
                      }),
                    );
                  }

                  return resolve();
                })
                .catch(reject);