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.

Access required field on a field in the schema

See original GitHub issue

Once the schema is formed with shape(), it would be nice to be able to look a field up and see if it has ‘required’ set on it.

The idea being that I can use the information coded in the schema to set the required field on a MUI TextField.

I see that I can dive into the object and grab the data out of the schema.fields[NAME]._exclusive.required property, but that seems pretty hardcore.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
maximilianoforlenzacommented, Sep 30, 2020

@jquense One question, how can I get the required fields using when? I’ve found this comment https://github.com/formium/formik/issues/1241#issuecomment-547452352. Using when schema.describe().fields[field].tests returns an empty array

3reactions
kusmierzcommented, Dec 3, 2019

@lookfirst, maybe add something like:

schema.isRequired('name'); // returns boolean
isFieldRequired(field) {
  return this.describe().fields[field].tests.findIndex(({ name }) => name === 'required') >= 0;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Require a value in a field - Microsoft Support
In the Navigation Pane, right-click the table and then click Design View. · Select the field that you want to require always has...
Read more >
Access to required fields with Yup - Stack Overflow
I use react-hook-form with yup to validate my forms. I want to know all required fields ...
Read more >
Access- Required Field - YouTube
Access - Required Field. 4.2K views 6 years ago ... Indexing Fields in Microsoft Access Tables for Optimal Database Performance.
Read more >
Creating a Basic Access Database - Required Fields - YouTube
+ If you enjoy these tutorials, and want to build it into a project of ...
Read more >
Using Access 2010 - Make a Field Required - YouTube
Using Access 2010 - Make a Field Required. ... to Use MS Access to Make a Database - Tutorials for Microsoft Office Specialist...
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