Skip to content

Commit

Permalink
fix(web): pipe all valibot transform
Browse files Browse the repository at this point in the history
  • Loading branch information
GervinFung committed Jul 21, 2024
1 parent 6d84671 commit 805d475
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
13 changes: 1 addition & 12 deletions apps/web/pages/templates/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {

import styled from '@emotion/styled';

import { parse, object, array, string, transform, nullable } from 'valibot';
import { parse, object, array, string } from 'valibot';

import Fuse from 'fuse.js';

Expand Down Expand Up @@ -55,17 +55,6 @@ type Template = Templates[number];

const schemas = {
names: string(),
cacheOrdinaryTemplates: transform(
nullable(
array(
object({
name: string(),
content: string(),
})
)
),
Optional.from
),
selectedOrdinaryTemplatesId: array(
object({
value: string(),
Expand Down
17 changes: 10 additions & 7 deletions apps/web/src/api/scrapper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@ import { AsyncOperation, Defined } from '@poolofdeath20/util';

import axios from 'axios';

import { parse, object, array, string, transform } from 'valibot';
import { parse, object, array, string, transform, pipe } from 'valibot';
import { singleFlowParser } from '../../common/parser';

const schemas = {
latestTimeCommitted: transform(string(), (value) => {
return new Date(value);
}),
latestTimeCommitted: pipe(
string(),
transform((value) => {
return new Date(value);
})
),
template: {
properties: {
content: string(),
},
list: array(
transform(
pipe(
object({
path: string(),
}),
({ path }) => {
transform(({ path }) => {
return path;
}
})
)
),
},
Expand Down

0 comments on commit 805d475

Please sign in to comment.