Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dhurley14 committed Dec 4, 2024
1 parent 1881b1b commit a8f3428
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
2 changes: 0 additions & 2 deletions packages/kbn-openapi-common/schemas/primitives.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ components:
schemas:
NonEmptyString:
type: string
# pattern: ^(?! *$).+$
minLength: 1
# format: trim
format: nonempty
description: A string that is not empty and does not contain only whitespace

Expand Down
1 change: 1 addition & 0 deletions packages/kbn-zod-helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ export * from './src/required_optional';
export * from './src/safe_parse_result';
export * from './src/stringify_zod_error';
export * from './src/build_route_validation_with_zod';
export * from './src/non_empty_string';
9 changes: 0 additions & 9 deletions packages/kbn-zod-helpers/src/is_valid_date_math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,3 @@ export function isValidDateMath(input: string, ctx: z.RefinementCtx) {
});
}
}

export function isNonEmptyString(input: string, ctx: z.RefinementCtx) {
if (typeof input === 'string' && input.trim() === '') {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: 'No empty strings allowed',
});
}
}
18 changes: 18 additions & 0 deletions packages/kbn-zod-helpers/src/non_empty_string.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import * as z from '@kbn/zod';
export function isNonEmptyString(input: string, ctx: z.RefinementCtx) {
if (typeof input === 'string' && input.trim() === '') {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: 'No empty strings allowed',
});
}
}

0 comments on commit a8f3428

Please sign in to comment.