java custom validator with dynamic messages, isvalid code example
Example 1: system.in example in java
package com.mkyong.io;
import java.util.Scanner;
public class JavaScanner {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String input = "";
while (!"q".equalsIgnoreCase(input)) {
System.out.print("Enter something (q to quite): ");
input = scanner.nextLine();
System.out.println("input : " + input);
}
System.out.println("bye bye!");
}
}
Example 2: Parallax.js wrapper for react
import React, { Component } from 'react'
import Parallax from 'parallax-js'
class ParallaxComponent extends Component {
componentDidMount() {
this.parallax = new Parallax(this.scene)
}
componentWillUnmount() {
this.parallax.disable()
}
render() {
render (
<ul ref={el => this.scene = el}>
<li className="layer" dataDepth="0.00">
<img src="layer1.png"/>
</li>
<li className="layer" dataDepth="0.50">
<img src="layer2.png"/>
</li>
<li className="layer" dataDepth="1.00">
<img src="layer3.png"/>
</li>
</ul>
)
}
}