Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Dermot Haughey
@hderms
or something like that
how would a frontend client be able to map a given error to a given element
it seems like the output of the validation descriptions is useful for a human to read but not very machine-readable
Tomer Gabel
@holograph
Ah. Well it's designed for dealing with paths in case classes, but I think #21 would cover this use case as well. There's a lot to figure out first, though, in terms of sane DSL -- perhaps @NoamSon_twitter would have some ideas as well
Dermot Haughey
@hderms
I am mapping the request to a case class
before validating it
but I find the error messages unfortunately not particularly useful for the use case I'm describing
http://dry-rb.org/gems/dry-validation/ has the kind of output i think is more useful for consuming clients:
Tomer Gabel
@holograph
It's mapping it back that much be difficult. There is quite a principled path structure already in place that could potentially be parsed on the client side in a consistent manner, but this may not be 100% usable in your use case
Dermot Haughey
@hderms
yeah there might be a good way to do it that i'm not thinking of
Jan Trtík
@honzatrtik

hello!
trying to set up basic test with ResultMatchers like this:

import org.scalatest.{FlatSpec, Matchers}
import com.wix.accord._
import com.wix.accord.dsl._
import com.wix.accord.scalatest.ResultMatchers


object PrimitiveSchema {
  case class Person( firstName: String, lastName: String )
  case class Classroom( teacher: Person, students: Seq[ Person ] )

  implicit val personValidator = validator[ Person ] { p =>
    p.firstName is notEmpty
    p.lastName is notEmpty
  }

  implicit val classValidator = validator[ Classroom ] { c =>
    c.teacher is valid
    c.students.each is valid
    c.students have size > 0
  }
}


class TestSpec extends FlatSpec with Matchers with ResultMatchers {

  it should "validate The Person"  in {
    val sample = PrimitiveSchema.Person( "Wernher", "von Braun" )
    val result = validate( sample )
    result should be aSuccess
  }

}

but the compiler says:

Error:(29, 22) value aSuccess is not a member of TestSpec.this.ResultOfBeWordForAny[com.wix.accord.Result]
    result should be aSuccess

accord 0.7.2
scala 2.12.6

thanks for any help!
Im at the beggining of scala journey, so Im probably missing something obvious..

Jan Trtík
@honzatrtik
ok, replacing result should be aSuccess with result shouldBe aSuccess was enough ;-) shame on me
Tomer Gabel
@holograph
No worries :-) Glad it works for you!
lightningudemy
@lightningudemy
Good afternoon all, I am seeking help with copying code from CodePen.io to my Wix.com website
Tomer Gabel
@holograph
@lightningudemy This isn’t a Wix.com-related channel, only specifically about the Accord library. Sorry
lightningudemy
@lightningudemy
No problem @holograph, Thank you for your prompt response.
Zach Banducci
@zchbndcc9
What is the status on the 2.13 integration?
joules-o
@joules-o
Hi all, to what extent does Accord use runtime reflection?
Tomer Gabel
@holograph
Generally, Accord doesn’t use runtime reflection at all. Exceptions include Spring integration, and a handful of structural type-based validates (because that’s how Scala implements those).
Tomer Gabel
@holograph
*validators
joules-o
@joules-o
Cool, thank you!
lightningudemy
@lightningudemy

Good afternoon all, I am seeking information on where I went wrong with my code. I am receiving an error code stating the public key could not be found.

Here is my backend code:

import {fetch} from 'wix-fetch';  
import {wixData} from 'wix-data';


export function postLoyalty() {
 let options ={
 "headers": {        
 "X-Public": "pk_live_ba43e74df464cbf521dd07ee20443ff754c3afc11adc16df2594facb2147cd76"
        }
  }
 const url = 'https://whisqr.com/api/v1.2/user/customer/';
 const key = '<pk_live_ba43e74df464cbf521dd07ee20443ff754c3afc11adc16df2594facb2147cd76>';
     console.log("Url: ");

 return fetch(url, {method: 'post'})
    .then(response => {
 return response.json();
    })
    .then((data) => {
      console.log(data);
 return data;
    });
}

Here is my page code

import {postLoyalty} from 'backend/Loyalty.jsw';
import {wixData} from 'wix-data';
import wixLocation from "wix-location";
import {myFunction} from 'public/core.js';
import wixUsers from 'wix-users';


$w.onReady(function () {
 let publickey = 'pk_live_ba43e74df464cbf521dd07ee20443ff754c3afc11adc16df2594facb2147cd76';
    myFunction(publickey)
    .then( (response) => {
        console.log(response); //your base64 encoded string
    })});

export function page1_viewportEnter(event) {
 //Add your code for this event here: 
 let email = wixUsers.currentUser.getEmail();
postLoyalty(email)
        .then(LoyaltyInfo => {
            console.log(LoyaltyInfo)
            $w("#text1").text = LoyaltyInfo.Results.Value;
        })
}

I know this is a lot but I am at my wits end on how to deal with this. Any and all feedback is greatly appreciated!

Yutao Zhang
@lava1206
Hello
How are you doing?
I am going to add rating function to wix estore site and I need help on how to do it. I have searched the video and tried to find way, but it's all demo and not the way I want.
I want users can submit reviews and rating and they can see the overall rating of the service. The idea is clear, but due to the lack of wix experience I can't even edit current service page. I am open to anyone's voice who has similar experience.
Yutao Zhang
@lava1206
I am STUCK right now and really WANT your HELP.
Thank you first
Tomer Gabel
@holograph
@lava1206 @lightningudemy As I have previously explained, this channel pertains specifically to the Accord library. Most people here aren’t necessarily knowledgeable about Wix Code, and in either case this isn’t the right channel for these questions.
Yutao Zhang
@lava1206
@holograph I see thank you
where are the real wix chat room
none of them are responding
all are vain rooms
Tomer Gabel
@holograph
Sorry @lava1206, I honestly don’t have a clue, I was in a different group and no longer employed by Wix regardless
Yutao Zhang
@lava1206
OK, thank you
Fredrik Wärnsberg
@frekw
I can't seem to figure out a good way to do dependent validation. I.e I want to specify a validation for some input objects, but in order to determine if the input is valid or not I need some other pieces of data. I guess a super simple example would be something like
case class ReplaceInStringVector(
  index: Int,
  value: String
)

implicit val replaceValidator = validator[ReplaceInStringVector] { r =>
  r.index should be >= 0
  r.index should be <= vector.length // <- how to get vector in here
}
So what I'm currently doing is doing it in two passes, where the first one uses Accord and a second pass uses plain logic, but returns the same datastructures as Accord. But it doesn't feel super elegant
I've also toyed with defining validations for e.g Tuple[ReplaceInStringVecotor, Vector[String]], but that mangles the validation errors quite a bit :)
Tomer Gabel
@holograph
You should be able to refer to static members (I.e. companion objects), or even class members if you’re instantiating your validators on the fly
Tomer Gabel
@holograph
Fredrik Wärnsberg
@frekw
@holograph ah, clever! I'll try it out tomorrow. Thanks!
Tomer Gabel
@holograph
@frekw Cool, let me know if that helps or not :-)
Fredrik Wärnsberg
@frekw
Still sorta new to Scala, neat that you can dynamically define implicits like that :)
I don't know why I always considered them as static
Tomer Gabel
@holograph
They’re often used as statics, but nothing is forcing you to do so...
Fredrik Wärnsberg
@frekw
Is it possible to make validators short-circuit somehow using and? I.e get this to work?
(r.index is between (0, v.length - 1)) and (r.value == v(r.index))
(I could use if, but then I need to implement the index check twice)
Tomer Gabel
@holograph
Not without a custom validator; the rationale is that, For validation, you want ALL rules to be evaluated (in order to produce a full error). That’s why and doesn’t short circuit.
Fredrik Wärnsberg
@frekw
Ah, fair enough