You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some thoughts at the top of my head as I figure out how to get a lexicon validator that works, especially one for my needs.
Reduce the ambient module declarations to just the stuff necessary to get the typed HTTP client working, rename the module specifier to be something like @atcute/lexicons/http
Lexicon types should be imported from their respective packages, app.bsky.* lexicons should be imported from @atcute/bluesky, same goes for @atcute/whitewind and so on.
Move com.atproto.* lexicons to a separate @atcute/atproto package
Some of these aren't strictly necessary, but given that these type declarations and lexicon validations are pretty nifty for anyone using it outside of the typed HTTP client, I should at least accomodate for it for my next chance at revisiting this
We could provide validateX and isX functions just like what @atproto/api is providing, however:
Only validateX provides a safe-parsing functionality
isX is used to check whether the object in question either has no $type field, or the field exists and matches the expected type for that object.
There's like 3 different ways to validate data, and they're all neat for their own cases.
if(v.is(AppBskyFeedPost.Record,record)){// handy if you just want to know if it's valid}// this one throws, handy for anything that requires the value to exactly matchv.parse(AppBskyFeedPost.Record,record);// this one doesn't throw, if it returns `ok: false` you can deal with the error however you see fitv.safeParse(AppBskyFeedPost.Record,record);
The text was updated successfully, but these errors were encountered:
Some thoughts at the top of my head as I figure out how to get a lexicon validator that works, especially one for my needs.
@atcute/lexicons/http
app.bsky.*
lexicons should be imported from@atcute/bluesky
, same goes for@atcute/whitewind
and so on.com.atproto.*
lexicons to a separate@atcute/atproto
packageSome of these aren't strictly necessary, but given that these type declarations and lexicon validations are pretty nifty for anyone using it outside of the typed HTTP client, I should at least accomodate for it for my next chance at revisiting this
We could provide
validateX
andisX
functions just like what@atproto/api
is providing, however:validateX
provides a safe-parsing functionalityisX
is used to check whether the object in question either has no$type
field, or the field exists and matches the expected type for that object.There's like 3 different ways to validate data, and they're all neat for their own cases.
The text was updated successfully, but these errors were encountered: