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

set same validators warnings for multiple values? #6

Closed
debpalash opened this issue Aug 1, 2022 · 11 comments
Closed

set same validators warnings for multiple values? #6

debpalash opened this issue Aug 1, 2022 · 11 comments

Comments

@debpalash
Copy link
Contributor

like how to do this?

validators: {
        email: [
          requiredValidator("This field is required"),
          emailValidator("Value should be email!"),
        ],
        name,id,captcha:[
          requiredValidator("This field is required")
        ],

can do currently:

const { register, submit, loading, getAllValues, getValue, setValue, errors, watch } =
    createForm<{ email: string; name: string, password: string, id: string, captcha: boolean }>({
      initialValues: {
      },
      validators: {
        email: [
          requiredValidator("This field is required"),
          emailValidator("Value should be email!"),
        ],
        name: [
          requiredValidator("This field is required"),
        ],
        id: [
          requiredValidator("This field is required"),
        ],
        password: [
          requiredValidator("This field is required"),
        ],
        captcha: [
          requiredValidator("Solving captcha is required"),
        ]
      },
@debpalash
Copy link
Contributor Author

also @ragokan 1.0.6 working as expected :) thanks for swift update. I've tried few other forms but your's simple enough for my solidJS noobie 😂

@ragokan
Copy link
Owner

ragokan commented Aug 1, 2022

also @ragokan 1.0.6 working as expected :) thanks for swift update. I've tried few other forms but your's simple enough for my solidJS noobie 😂

Heyy, currently we can't do something like "name,id,captcha" but instead we can make a workaround. Firstly, you don't have to add array for each. These are same;

  password: [
     requiredValidator("This field is required"),
  ],
  password:  requiredValidator("This field is required"),

Till someone implements or I find time to implement it, we can do something like:

const req =  requiredValidator("This field is required");
...
 password:  req,
 captcha: [req, minLength("Solving captcha is required")],
 ...

@ragokan
Copy link
Owner

ragokan commented Aug 1, 2022

also @ragokan 1.0.6 working as expected :) thanks for swift update. I've tried few other forms but your's simple enough for my solidJS noobie 😂

Thank you for your comment, it made my day :)

@debpalash
Copy link
Contributor Author

debpalash commented Aug 1, 2022

const req =  requiredValidator("This field is required");
...
 password:  req,
 captcha: [req, minLength("Solving captcha is required")],
 ...

It's so obvious that it's emberassing to open an issue for 😂

| Thank you for your comment, it made my day :)

Well you saved my day so thank you :)

@ragokan
Copy link
Owner

ragokan commented Aug 1, 2022

const req =  requiredValidator("This field is required");
...
 password:  req,
 captcha: [req, minLength("Solving captcha is required")],
 ...

It's so obvious that it's emberassing to open an issue for 😂

| Thank you for your comment, it made my day :)

Well you saved my day so thank you :)

It is definitely not embarrassing, don't worry. Nice to see some people use the package 💯 I will also try to implement using rules for multiple keys at the same time. Take care, have fun!

@debpalash
Copy link
Contributor Author

It is definitely not embarrassing, don't worry. Nice to see some people use the package 💯 I will also try to implement using rules for multiple keys at the same time. Take care, have fun!

well yes, that would be nice. Is there a option to disable submit before required inputs and a redirect or a catch form response handler?

@ragokan
Copy link
Owner

ragokan commented Aug 1, 2022

It is definitely not embarrassing, don't worry. Nice to see some people use the package 💯 I will also try to implement using rules for multiple keys at the same time. Take care, have fun!

well yes, that would be nice. Is there a option to disable submit before required inputs and a redirect or a catch form response handler?

I am planning to implement an eager validation system just like you ask, so that you can disable the button if the form is not valid.

@debpalash
Copy link
Contributor Author

debpalash commented Aug 1, 2022

cool. Do you think onSubmit => redirect function and handler for form response also could fit in?

@ragokan
Copy link
Owner

ragokan commented Aug 1, 2022

cool. Do you think onSubmit => redirect function and handler for form response also could fit in?

Well, even though I didn't understand it totally, I think yes

@debpalash
Copy link
Contributor Author

sorry, what i mean, i'm making a form which redirects user to another page after successful submission and before it shows a response from the onsubmit function. Guessing most use cases will have these kind of requriements. Solidjs is getting traction this year i think solform could be the go to form :)

@ragokan
Copy link
Owner

ragokan commented Aug 1, 2022

sorry, what i mean, i'm making a form which redirects user to another page after successful submission and before it shows a response from the onsubmit function. Guessing most use cases will have these kind of requriements. Solidjs is getting traction this year i think solform could be the go to form :)

Ahh, got it now. I hope it becomes the go to form 💯 Thank you for your review, see you later and ask me anything if you require.

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

No branches or pull requests

2 participants