Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V4] Update documentation #938

Open
6 of 12 tasks
rvsia opened this issue Jan 18, 2021 · 10 comments
Open
6 of 12 tasks

[V4] Update documentation #938

rvsia opened this issue Jan 18, 2021 · 10 comments
Labels
docs docs pull requests State manager Form state manager packages. Will be used a state management package for the form renderer. v4

Comments

@rvsia
Copy link
Contributor

rvsia commented Jan 18, 2021

Scope: Docs

Description

Update documentation:

  • form state manager details
    • form props
    • form state
    • field props
    • field state
  • new imports esm/cjs
    • toggle in code examples
  • required css loaders for
    • ant
    • PF4
  • remove links to react-final-form
  • migration guide v2 > v3
@rvsia rvsia added docs docs pull requests State manager Form state manager packages. Will be used a state management package for the form renderer. v3 labels Jan 18, 2021
@rvsia rvsia added v4 and removed v3 labels Mar 1, 2021
@rvsia rvsia changed the title [V3] Update documentation [V4] Update documentation Mar 1, 2021
@zgover
Copy link
Member

zgover commented Jun 9, 2021

@rvsia Please also add documentation for api usage of manual validation. It would be great to use the schema to validate posted field values on server side without rendering.

@Hyperkid123
Copy link
Member

@zgover can you provide a simple example?

@zgover
Copy link
Member

zgover commented Jun 9, 2021

@Hyperkid123 Say form values were posted to an API /api/endpoint?schemaId=123&[email protected]&...

While processing the request to verify the parameters/values were valid using a defined schema

const schema = {
  fields: [
    { name: email, validate: [{type: 'required'}, {type: 'pattern', pattern: '^...$', message: 'Invalid email' }]
  }
}

function handler(req, res) {
  const { query: { schemaId, ...fieldValues } }  = req
  const invalidFields = validateFields(schema, fieldsValues)
  if (invalidFields.length > 0) {
    return res.status(400).json({ status: 'error', error: { field_errors: invalidFields, ... } })
  }
  res.status(200).json({ status: 'success', code: 200 })
}

@Hyperkid123
Copy link
Member

Ah, I see. There should be similar functionality on the submit event. This would basically fall into the global validation category but instead of evaluating it client-side function, we would wait for a Promise response.

@rvsia
Copy link
Contributor Author

rvsia commented Jun 9, 2021

@zgover So, you want to have a separate "validation engine" based on the DDF schema to use outside the form renderer, right? This sounds like an interesting idea! 🤔

@zgover
Copy link
Member

zgover commented Jun 9, 2021

Maybe something available before v4? Should be easy to implement without breaking changes.

@rvsia
Copy link
Contributor Author

rvsia commented Jun 9, 2021

@zgover Yeah, I will take a look on it today. And it would be a definitely just an addition, so we can release it asap.

@Hyperkid123
Copy link
Member

The validation engine is available even now. It's just not prepared to "consume" schema but only a field state.

@rvsia
Copy link
Contributor Author

rvsia commented Jun 10, 2021

@zgover Hello, the standalone validation has been released, you can check it here: https://data-driven-forms.org/utilities/standalone-validation

@zgover
Copy link
Member

zgover commented Jun 10, 2021

Much appreciate the quickness @rvsia and @Hyperkid123

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs docs pull requests State manager Form state manager packages. Will be used a state management package for the form renderer. v4
Projects
None yet
Development

No branches or pull requests

3 participants