0.0.6-alpha.8 • Published 3 years ago

@last-rev/content-validator v0.0.6-alpha.8

Weekly downloads
2
License
ISC
Repository
-
Last release
3 years ago

LastRev Content Validator

This module provides a set of useful components to catch Content validation errors and provides a DOM API to expose validation errors to extensions.

usage

First you'll need to setup the ContentValidationProvider by wrapping your root component with it.

import { ContentValidationProvider } from '@last-rev/content-validator';

// This default export is required in a new `pages/_app.js` file for Next.js.
function MyApp({ Component, pageProps }) {
   return (
    <ContentValidationProvider logLevel="ERROR"> // Default is DEBUG which only logs the errors
          <Component {...pageProps} />
    </ContentValidationProvider>
  );

You can use this module as a HOC by wrapping the default export with it:

//From
export default SectionQuote;

//To
export default withContentValidation({
  schema: yup.object({
    content: yup.object({
      quoteText: yup.string().required(),
      attribution: yup.string().required()
    })
  })
})(SectionQuote);

This will parse the propTypes of the component, check for any errors and TRY to render the component.

If the component fails to render it'll just return null and you can get the errors from the HTML.

You can also pass options when calling the HOC to configure the usage:

export default withContentValidation({
  logLevel: 'ERROR'
})(ElementLink);
// DEBUG: This is the default, it will log the error and inject DOM attributes
// ERROR: will throw the Error to be handled

Documentation

Official documentation can be found here.

0.0.6-alpha.8

3 years ago

0.0.6-alpha.7

3 years ago

0.0.6-alpha.5

3 years ago

0.0.6-alpha.6

3 years ago

0.0.6-alpha.3

3 years ago

0.0.6-alpha.4

3 years ago

0.0.6-alpha.1

3 years ago

0.0.6-alpha.2

3 years ago

0.0.5-alpha.11

3 years ago

0.0.5-alpha.10

3 years ago

0.0.5-alpha.9

3 years ago

0.0.5-alpha.8

3 years ago

0.0.5-alpha.2

3 years ago

0.0.5-alpha.3

3 years ago

0.0.5-alpha.4

3 years ago

0.0.5-alpha.5

3 years ago

0.0.5-alpha.6

3 years ago

0.0.5-alpha.7

3 years ago

0.0.5-alpha.0

3 years ago

0.0.4

3 years ago

0.0.2

3 years ago

0.0.2-alpha.22

3 years ago

0.0.2-alpha.20

3 years ago

0.0.2-alpha.19

3 years ago

0.0.2-alpha.18

3 years ago

0.0.2-alpha.17

3 years ago

0.0.2-alpha.16

3 years ago

0.0.2-alpha.15

3 years ago

0.0.2-alpha.14

3 years ago

0.0.2-alpha.13

3 years ago

0.0.2-alpha.12

3 years ago

0.0.2-alpha.11

3 years ago

0.0.2-alpha.10

3 years ago

0.0.2-alpha.9

3 years ago

0.0.2-alpha.8

3 years ago

0.0.2-alpha.7

3 years ago

0.0.2-alpha.6

3 years ago

0.0.2-alpha.5

3 years ago

0.0.2-alpha.4

3 years ago

0.0.2-alpha.3

3 years ago

0.0.2-alpha.2

3 years ago

0.0.2-alpha.1

3 years ago