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

feat: builder api #97

Merged
merged 8 commits into from
May 12, 2021
Merged

feat: builder api #97

merged 8 commits into from
May 12, 2021

Conversation

mixvar
Copy link
Collaborator

@mixvar mixvar commented May 3, 2021

closes #93

published as 0.2.8-beta.2 (see sandbox)

example:

import { FormSchemaBuilder, FormFields, FormValidatorBuiler } from "@virtuslab/formts";

const Schema = new FormSchemaBuilder()
  .fields({ answer: FormFields.string() })
  .errors<string>()
  .build();

const validator = new FormValidatorBuilder(Schema)
  .validate(
    Schema.answer,
    val => (val === "" ? "Required!" : null),
    val => (val !== "42" ? "Wrong answer!" : null)
  )
  .build();

@mixvar mixvar requested a review from pidkopajo May 3, 2021 15:19
@mixvar mixvar merged commit f78bd91 into master May 12, 2021
@mixvar mixvar deleted the feat/builder-api branch May 12, 2021 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

builder based API
2 participants