create-secret.schema.tsx•1.99 kB
/**
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
* http://github.com/fonoster/fonoster
*
* This file is part of Fonoster
*
* Licensed under the MIT License (the "License");
* you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* https://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { zodResolver } from "@hookform/resolvers/zod";
import { z } from "zod";
/**
* Zod validation schema for the Create Secret form.
*
* Defines the expected structure and validation rules for creating or updating a secret.
* Includes:
* - ref: Optional unique identifier for the secret.
* - name: Required friendly name.
* - secret: Required secret value.
* - type: String indicating the type of secret (e.g., text, json).
*/
export const schema = z.object({
/**
* Unique identifier for the credential.
*
* Optional; may be generated by the system or assigned manually.
*/
ref: z.string().nullish(),
/**
* Human-friendly name for the credential.
*
* Required; must not be empty.
*/
name: z.string().nonempty("Friendly Name is required"),
/**
* Secret value associated with the credential.
*
* Required; must not be empty.
*/
secret: z.string().nonempty("Secret is required"),
/**
* Type of the secret (e.g., 'text' or 'json').
*
* Required; used to determine how the secret value should be handled.
*/
type: z.string()
});
/**
* Type representing the validated data structure returned by the schema.
*
* Useful for typing form state, submission handlers, and data processing.
*/
export type Schema = z.infer<typeof schema>;