tailcall icon indicating copy to clipboard operation
tailcall copied to clipboard

feat: Add @validate directive for custom scalar validation

Open amitksingh1490 opened this issue 9 months ago • 12 comments

Description: Currently, Tailcall allows developers to define custom scalars. However, there's no built-in way to add validations on those custom scalars. I propose creating a @validate directive which takes js function as input and can be applied on scalars. The js function inside @validate should return either true or false. If it returns false, the user should receive a Evaluation error when an invalid value is passed into the scalar.

Expected Behavior:

  • The @validate directive should be applicable to custom scalar types.
  • The directive js function should return true for valid values and false for invalid values.
  • If the directive returns false, a Evaluation error should be thrown to indicate the issue to the user.

Tasks:

  • [ ] Implement a @validate directive that developers can use on custom scalars.
  • [ ] @validate accepts a js function as input.
  • [ ] errors should follow the formatting guidelines of Tailcall Evaluation Errors

Example

scalar EvenNumber @validate(js: "isEven")
function isEven(num) {
	return num % 2 === 0
}

amitksingh1490 avatar May 03 '24 06:05 amitksingh1490

/bounty 100

tusharmath avatar May 04 '24 09:05 tusharmath

~~## 💎 $100 bounty • Tailcall Inc.~~

~~### Steps to solve:~~ ~~1. Start working: Comment /attempt #1847 with your implementation plan~~ ~~2. Submit work: Create a pull request including /claim #1847 in the PR body to claim the bounty~~ ~~3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts~~

~~🙏 Thank you for contributing to tailcallhq/tailcall!~~ ~~🧐 Checkout our guidelines before you get started.~~ ~~💵 More about our bounty program.~~

Attempt Started (GMT+0) Solution
🔴 @webbdays May 4, 2024, 9:22:15 AM WIP
🔴 @mobley-trent May 7, 2024, 2:39:49 PM WIP
🔴 @beelchester Aug 6, 2024, 3:01:42 AM WIP

algora-pbc[bot] avatar May 04 '24 09:05 algora-pbc[bot]

/attempt

Algora profile Completed bounties Tech Active attempts Options
@webbdays 2 tailcallhq bounties
Python, Rust,
JavaScript & more
Cancel attempt

webbdays avatar May 04 '24 09:05 webbdays

@webbdays: Reminder that in 1 days the bounty will become up for grabs, so please submit a pull request before then 🙏

algora-pbc[bot] avatar May 05 '24 09:05 algora-pbc[bot]

The bounty is up for grabs! Everyone is welcome to /attempt #1847 🙌

algora-pbc[bot] avatar May 06 '24 09:05 algora-pbc[bot]

/attempt #1847

Algora profile Completed bounties Tech Active attempts Options
@mobley-trent 2 tailcallhq bounties
Python, Rust,
Jupyter Notebook
Cancel attempt

mobley-trent avatar May 07 '24 14:05 mobley-trent

💡 @mobley-trent submitted a pull request that claims the bounty. You can visit your bounty board to reward.

algora-pbc[bot] avatar May 07 '24 16:05 algora-pbc[bot]

@mobley-trent are you still on this?

webbdays avatar May 18 '24 03:05 webbdays

Feel free to pick up the issue @webbdays

mobley-trent avatar May 18 '24 06:05 mobley-trent

Action required: Issue inactive for 30 days. Status update or closure in 7 days.

github-actions[bot] avatar Jun 19 '24 20:06 github-actions[bot]

/attempt #1847

Algora profile Completed bounties Tech Active attempts Options
@beelchester 8 tailcallhq bounties
Rust, TypeScript,
Go & more
Cancel attempt

beelchester avatar Aug 06 '24 03:08 beelchester

@beelchester: Reminder that in 1 days the bounty will become up for grabs, so please submit a pull request before then 🙏

algora-pbc[bot] avatar Aug 07 '24 03:08 algora-pbc[bot]

The bounty is up for grabs! Everyone is welcome to /attempt #1847 🙌

algora-pbc[bot] avatar Aug 08 '24 03:08 algora-pbc[bot]

Action required: Issue inactive for 30 days. Status update or closure in 7 days.

github-actions[bot] avatar Sep 07 '24 03:09 github-actions[bot]

Issue closed after 7 days of inactivity.

github-actions[bot] avatar Sep 14 '24 03:09 github-actions[bot]