Skip to content

Rating

Interface

export type IRatingTypeValue = number | null;
 
export interface IRatingField extends CommonField {
    type: 'rating';
    options?: {
        score: number;
        step: 0.5 | 1;
    };
    private?: () => Promise<IRatingTypeValue>;
    render?: (v: IRatingTypeValue) => JSX.Element;
    validation?: Validation<IRatingTypeValue>;
}

Example

Basic Rating Field

{
  type: 'rating',
  name: 'YOUR_PATH',
  validation: z.number().min(0).max(5).nullable()
}

Custom Rating Field

{
  type: 'rating',
  name: 'YOUR_PATH',
  options: {
    score: 8,
    step: 0.5
  },
  validation: z.number().min(0).max(5).nullable()
}