class-validator#isISO8601 TypeScript Examples

The following examples show how to use class-validator#isISO8601. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: shared.dto.ts    From affinidi-core-sdk with Apache License 2.0 5 votes vote down vote up
@IsOptional()
  @IsISO8601()
  expiresAt?: string
Example #2
Source File: shared.dto.ts    From affinidi-core-sdk with Apache License 2.0 5 votes vote down vote up
@IsOptional()
  @IsISO8601()
  issued?: string
Example #3
Source File: shared.dto.ts    From affinidi-core-sdk with Apache License 2.0 5 votes vote down vote up
@IsOptional()
  @IsISO8601()
  expires?: string
Example #4
Source File: shared.dto.ts    From affinidi-core-sdk with Apache License 2.0 5 votes vote down vote up
@IsOptional()
  @IsISO8601()
  issuanceDate?: string
Example #5
Source File: shared.dto.ts    From affinidi-core-sdk with Apache License 2.0 5 votes vote down vote up
@IsOptional()
  @IsISO8601()
  expirationDate?: string
Example #6
Source File: shared.dto.ts    From affinidi-core-sdk with Apache License 2.0 5 votes vote down vote up
@IsOptional()
  @IsISO8601()
  expiresAt?: string
Example #7
Source File: ParametersValidator.ts    From affinidi-core-sdk with Apache License 2.0 5 votes vote down vote up
static validatePrimitive(schema: string, value: any) {
    let message: string
    let isValid: boolean = true

    switch (schema) {
      case did:
        isValid = matches(value, DID)
        message = `Parameter "${value}" is not a valid. Valid format: (${DID}).`
        break

      case didMethod:
        isValid = matches(value, DID_METHOD)
        message = `Parameter "${value}" is not a valid. Valid format: (${DID_METHOD}).`
        break

      case jwt:
        isValid = matches(value, JWT)
        message = `Parameter "${value}" is not a valid JWT. Valid format: (${JWT}).`
        break

      case array:
        isValid = isArray(value)
        message = `Parameter "${value}" should be an array.`
        break

      case number:
        isValid = isNumber(value)
        message = `Parameter "${value}" should be a number.`
        break

      case object:
        isValid = isObject(value)
        message = `Parameter "${value}" should be an object.`
        break

      case string:
        isValid = isString(value)
        message = `Parameter "${value}" should be a string.`
        break

      case boolean:
        isValid = isBoolean(value)
        message = `Parameter "${value}" should be a boolean.`
        break

      case isoString:
        isValid = isISO8601(value)
        message = `Parameter "${value}" is not a valid ISO 8601 date string.`
        break

      case confirmationCode:
        isValid = matches(value, COGNITO_CONFIRMATION_CODE)
        message = `Parameter "${value}" is not a valid confirmation code. Valid format: (${COGNITO_CONFIRMATION_CODE}).`
        break

      case password:
        isValid = matches(value, PASSWORD)
        message = `Parameter "${value}" is not a password. Valid format: (${PASSWORD}).`
        break
    }

    return { isValid, message }
  }
Example #8
Source File: parse-date.pipe.ts    From aqualink-app with MIT License 5 votes vote down vote up
transform(value: string | undefined, metadata: ArgumentMetadata) {
    if (!isUndefined(value) && !isISO8601(value)) {
      throw new BadRequestException(`Date '${metadata.data}' is not valid`);
    }

    return value;
  }