question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Refinement for top level object failed when field has refinement

See original GitHub issue

Using the validators below, the top level PasswordDoNotMatch refinement will not be called. On the other hand, if we change to newPassword: string() (i.e. no refinement in any of the nested fields), then the PasswordDoNotMatch will be called.

const PasswordValidator = refine(string(), 'MinimumLength', (pw) => pw >= 8);
const ChangePasswordValidator = object({
    newPassword: PasswordValidator,
    confirmPassword: string(),
});
const RefinedChangePasswordValidator = refine(ChangePasswordValidator, 'PasswordDoNotMatch', (values) => {
    return values.newPassword == values.confirmPassword;  // This will not be called
});

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ianstormtaylorcommented, Jun 3, 2022

@Gelio that sounds great! Actually I believe there is already an error.refinement field which might give us exactly what we need to make that check in the run function.

1reaction
Geliocommented, Jun 3, 2022

Great! Sure, I’ll try to prepare something over the weekend.

Just to be clear, I will disambiguate the errors so that we have specific validator and refiner errors and then run the refiner if there were no validator errors on the value itself or its entries.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why did I get "main.using is permitted only at toplevel" when I ...
It's either a bug or a misfeature of IRb. It is well-known that due to the pretty hackish way IRb is implemented, it...
Read more >
LookML refinements | Looker - Google Cloud
Adapt and build on existing elements with LookML refinements.
Read more >
Refining Objects - CMU School of Computer Science
At the structural level dynamic dispatch may fail, but at ... able, showing that a program satisfies a refinement is, by Rice's Theorem,...
Read more >
Error-driven adaptive mesh refinement for unsteady turbulent ...
This case is relevant because of the difficulty to predict the separation of the flow induced by the presence of a curved surface...
Read more >
Learning to Refine Object Segments - Ronan Collobert
Object segmentation requires both object-level information ... M1 serves as the input to the top-down refinement module, which is responsi-.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found